部分文字列の位置を返す
strscan <string> <substring>
文字列 <string> の中に、 部分文字列  <substring> が含まれているかどうか調べる。
もし、  <substring> が見つかった場合、その位置(1オリジン)がシステム変数 result に格納される。
<substring> が複数含まれている場合、最初のものの位置が格納される。もし、 <substring> が見つからなかった場合、 result に0が格納される。
strscan 'tera term' 'term' ; result の値は6 int2str valstr result messagebox valstr 'result'
; 16進文字列を16進および2進へ変換する basenum='0060E3da' base=16 call base2dec int2str sdec decnum messagebox sdec 'decnum' base=2 call dec2base messagebox basenum 'basenum' end :dec2base basenum='' tmp=decnum ;modified so not destructive of decnum while tmp>0 strcopy '0123456789ABCDEF' (tmp%base)+1 1 basedig strconcat basedig basenum basenum=basedig tmp=tmp/base endwhile return :base2dec decnum=0 strlen basenum len=result for i 1 len strcopy basenum i 1 basedig decnum=decnum*base strscan '0123456789ABCDEFabcdef' basedig if result>16 result=result-6 ;take care of lower case decnum=decnum+result-1 next return
; IPアドレスのネットワークアドレスとサブネットマスクを求める
ip='192.168.1.189'
sn='255.255.255.248'
bits=0          ;calculate bits & first address in sn
bitstr='000 128 192 224 240 248 252 254 255'    ;lookup table for # bits
do
    str2int isn sn
    int2str stmp isn
    strscan bitstr stmp     ;use lookup table to find bits
    bits=bits+(result-1)/4  
    str2int tmp ip      ;find net by bitwise AND of ip and mask
    sprintf2 net '%s%d' net tmp&isn
    strscan sn '.'
    strcopy sn result+1 999 sn
    strscan ip '.'
    strcopy ip result+1 999 ip
    if result>0 strconcat net '.'           
loop while result>0
messagebox bits 'bits'
messagebox net 'net'