MOD ざざん
#define ctype strleft(%1,%2)strmid(%1,0,%2)
#define ctype strright(%1,%2)strmid(%1,-1,%2)
;#define ctype strmul(%1,%2)
s="aabbccdd"
mes strleft(s,2)
mes strleft(s,2+1)
mes strright(s,2)
mes strright(s,1+2)
mes strmul("ab",3)
mes strmul("ab",0)
mes strmul("ab",-1);error
mes subst("aaaaa",2,2,"zx")
mes subst("aaaaa",0,3,"lmno")
mes subst("aaaaa",2,3,"zx");error
mes subst("aaaaa",10,3,"lmno");error
mes subst("aaaaa",-1,3,"lmno");error
mes subst("aaaaa",0,-1,"lmno");error
stop
#defcfunc strmul str p_s,int p_i,local loc_s
if p_i < 0:dialog "strmul内のerror\np2の値は1以上にして下さい\np2:"+p_i,1:return-1
loc_s=""
repeat p_i
loc_s+=p_s
loop
return loc_s
#defcfunc subst str p_s,int p_begin,int p_num,str p_t,local loc_s,local loc_t,local loc_c,local loc_l,local loc_l_t,local loc_l_s
if p_begin<0:dialog "subst内のerror\np_beginの値が小さすぎます\np_begin:"+p_begin,1:return -1
if p_num<0:dialog "subst内のerror\np_numの値が小さすぎます\np_num:"+p_num,1:return -1
loc_s=p_s
loc_t=p_t
loc_c=0
loc_l=p_begin
loc_l_t=strlen(loc_t)
loc_l_s=strlen(loc_s)
if loc_l >=loc_l_s:dialog "subst内のerror\np_beginの値が大きすぎます\np_begin:"+p_begin,1
repeat p_num
if loc_l_t <= cnt:dialog "subst内のerror\nloc_l_tの値が大きすぎます\nloc_l_t:"+loc_l_t,1:break
loc_c=peek(loc_t,cnt)
if loc_l_s <= loc_l+cnt:dialog "subst内のerror\nloc_l_sの値が大きすぎます\nloc_l_s:"+loc_l_s,1:break
poke loc_s,loc_l+cnt,loc_c
loop
return loc_s
|