; ; objsend命令を使用したテキストエディタサンプル ; for HSP ver2.4d ; sdim info,8000 sdim ln,256 sdim buf,32000 mesbox buf,635,300,1 id=0 ; エディットボックスのオブジェクトID pos 8,310 button "LOAD",*file_load button "SAVE",*file_save button "CHECK",*chk1 button "MARGIN",*margin pos 88,310 button "GETLN",*getln button "R/O",*ronly button "RW OK",*rwok button "LIMIT",*limit pos 168,310 button "ROLL_U",*roll_u button "ROLL_D",*roll_d button "TOP",*go_top button "BOTTOM",*go_bottom stop *roll_u x=0:y=-1 objsend id,$b6,x,y,1 ; 指定した方向にスクロール objsel id ; mesboxにフォーカスを戻す stop *roll_d x=0:y=1 objsend id,$b6,x,y,1 ; 指定した方向にスクロール objsel id ; mesboxにフォーカスを戻す stop *go_top a=0 objsend id,$b1,a,a,1 ; カーソル位置を指定の場所に移動 a=0 objsend id,$b7,a,a,1 ; カーソルがある場所に画面を切り替える objsel id ; mesboxにフォーカスを戻す stop *go_bottom a=0 objsend id,$ba,a,a,1 ; 全体の行数を取得 b=stat a=0 objsend id,$bb,b-1,a,1 ; 変数bで指定した行のインデックスを取得 c=stat objsend id,$b1,c,c,1 ; カーソル位置を指定の場所に移動 a=0 objsend id,$b7,a,a,1 ; カーソル位置のある場所に画面を切り替える objsel id ; mesboxにフォーカスを戻す stop *margin b=8:c=10 ; 左マージンを8に、右マージンを10に a=c<<16+b objsend id,$d3,3,a,1 ; マージン設定をする objsel id ; mesboxにフォーカスを戻す stop *ronly a=0 objsend id,$cf,-1,a,1 ; 書き込み禁止フラグの設定 objsel id ; mesboxにフォーカスを戻す stop *rwok a=0 objsend id,$cf,0,a,1 ; 書き込み禁止フラグの設定解除 objsel id ; mesboxにフォーカスを戻す stop *limit a=0 objsend id,$c5,a,a,1 ; テキストリミットを最大に設定 objsel id ; mesboxにフォーカスを戻す stop *getln a=0 objsend id,$b0,0,a ; 変数aにカーソル位置の場所(byte)を取得 objsend id,$c9,a,b ; 変数bにカーソル位置の行インデックスを取得 b=stat notesel buf noteget ln,b strlen c,ln dialog "["+b+"行の内容("+c+"bytes)]\n"+ln objsel id ; mesboxにフォーカスを戻す stop *chk1 a=0 objsend id,$ba,a,a,1 ; 全体の行数を変数bに取得 b=stat info="[EDIT INFO]\n行数="+b+" / INDEX="+c+"\n" ; a=0 objsend id,$b0,0,a ; 変数aにカーソル位置の場所(byte)を取得 objsend id,$c9,a,b ; 変数bにカーソル位置の行インデックスを取得 b=stat info+="[CURSOR INFO]\nINDEX="+a+" / 現在行="+b+"\n" ; a=0 objsend id,$d4,a,a,1 ; マージン設定を変数b,cに取得 b=stat&$ffff:c=stat>>16 info+="[MARGINS]\n左余白="+b+" / 右余白="+c+"\n" ; a=0 objsend id,$d5,a,a,1 ; 最大テキストサイズを変数bに取得 b=stat info+="[LIMIT TEXT]\nMAX SIZE="+b+"\n" ; dialog info objsel id ; mesboxにフォーカスを戻す stop *file_save dialog "txt",17,"テキストファイル" if stat=0 : goto *dlcan strlen a,buf ; テキストの長さを調べる bsave refstr,buf,a ; テキストファイルをセーブ *dlcan objsel id ; mesboxにフォーカスを戻す stop *file_load dialog "txt",16,"テキストファイル" if stat=0 : goto *dlcan2 bload refstr,buf ; テキストファイル読み込み objprm id,buf *dlcan2 stop