y.tack製作(主にHSP)なmoduleを管理するwiki

#module
//	indexの値に関わらず文字列の始めが0から数えた値に
//	検索文字列を加えて返す関数
//	s1:調べる文字列
//	index:調べ始めるindex
//	s2:検索対象の文字列
//	昔書いた命令w
#defcfunc instr_LL var s1,int index,str s2,local loc_n,local loc_l
	await 1
//	文字列の中を検索
	loc_n=instr(s1,index,s2)
//	その文字列がないので-1を返す
	if loc_n==-1:return -1
	loc_l=strlen(s2)
//	あった文字列の場所に
//	検索開始位置と検索文字列の長さを加えて返す
	return loc_n+index+loc_l
//	配列に:の数を入れる
#deffunc count_colon_of_line_num array _4ret,local loc_n_c,local loc_str_c
	dim _4ret,notemax
	repeat notemax
		loc_str_c=""
		noteget loc_str_c,cnt
		loc_n_c=0
		while 1
			loc_n_c=instr_LL(loc_str_c,loc_n_c,":")
			if loc_n_c!=-1{
				_4ret.cnt++
			}else{
				_break
			}
		wend
	loop
	return
//	:がp_n個以上の数を数える
#defcfunc count_ar_bigger int p_n,array __4ret,local loc_count
	loc_count=0
	repeat length(__4ret)
		if __4ret.cnt >= p_n{
			loc_count++
		}
	loop
	return loc_count
#global

//*TEST CODE
sdim _4note,64000
notesel _4note
_4note="a\na:a\nb\nc:c:c\nd"
dim counts,notemax
mes notemax
//	配列に:の数を入れる
count_colon_of_line_num counts
mes ""
repeat notemax
mes counts.cnt
loop
mes ""
//	:が1個以上の数
mes count_ar_bigger(1,counts)
//	:が2個以上の数
mes count_ar_bigger(2,counts)
stop
//*/
タグ

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Menu

メニューサンプル1

メニューサンプル2

開くメニュー

閉じるメニュー

  • アイテム
  • アイテム
  • アイテム
【メニュー編集】

管理人/副管理人のみ編集できます