;;M:文字数カウント ver.2 ;知子のレコードの文字数を半角単位,全角単位で数える。 ;リターンはカウントしない。 ;正確な文字数です。 原稿用紙単位ではない。 ;日本の慣習とは違う数え方なので注意。 ;変数の定義 string s;   その行の文字列 integer total; 半角文字数トータル integer total2; 全角文字数 integer subtotal;半角文字数前段落まで integer danmoji; その段落の文字数 integer nline; 行数 integer nchar; その行の文字数 integer i; string ok; string a; integer code; integer nchar2; ; 準備 Setint(subtotal,0) SetInt(total, 0) SetInt(total2,0) CurTop; GetCountLine(nline) ;1行ずつカウントを実行 For(i,0, nline) GetCurLineStr(s) StrLen(nchar, s) incby(total, nchar) ;リターンが行の最後に入っているか判定する setint(nchar2,nchar) ;0を起点にしているため一つ減らす。そうでなければnchar2 はいらない。 dec(nchar2) GetStrAt(code, S, nchar2) CmpInt(code, '=', 13) ;システムフラグが立つ。最終行もこれでいいらしい。 Call(checkcode) CurDown endfor ;最後の処理 setstr(s,'文字数は半角単位で ') itoa(a,total) AddStr(s, a) addstr(s,'文字 : 全角単位で ') itoa(a,total2) AddStr(s, a) Addstr(s,' 文字') ShowMessage(s,0) exit :checkcode; 最後の文字が CR=13 の時の処理 RetIfFalse dec(total) setint(nchar2,total) decby(nchar2,subtotal) inc(nchar2) DivInt(nchar,nchar2,2) incby(total2,nchar) setint(subtotal,total) return