;================================================================================= ; ;llmod.asを使った各moduleの使用例 ; ;一つのファイルにごちゃごちゃ書いて見にくいかと思いますが ;じっくり見ればわかる思います ; ;================================================================================= #include "llmod.as" ;必ず必要 all_test=1 : if all_test : goto x1 goto x11 ;last 14 *x1 #include "msgdlg.as" msgdlg "今日はここで終了しますか?","プログラムの終了",3,5 if stat=6 : dialog "はい が選択されました" if stat=7 : dialog "いいえ が選択されました" if stat=2 : dialog "キャンセル が選択されました" if all_test : dialog "次へ進みます" : else stop *x2 #include "winver.as" ver=0 winver ver if ver=$100 : s="NT" : else s=ver mes "platform = Windows "+s mes "メジャーバージョン = "+ver.1 mes "マイナーバージョン = "+ver.2 mes "ビルドナンバー = "+ver.3 if (ver=95)|(ver=98) : mes "メジャー&マイナーバージョン"+ver.4 pos 250,0 file="kernel32.dll" : gosub dll_version file="user32.dll" : gosub dll_version file="comctl32.dll" : gosub dll_version if all_test : dialog "次へ進みます" : goto x3 : else stop *dll_version mes "■"+file+"のバージョン情報" repeat 8 verinfo file,cnt mes refstr : await loop return *x3 #include "about.as" about "llmodのバージョン情報#HSPモジュールファイル llmod ver 1.11","tom" if all_test : dialog "次へ進みます" : else stop *x4 #include "unicode.as" s="Unicodeに変換する文字列" to_uni buf,s,-1 usize=stat if usize=-1 : dialog "エラーが発生しました" if usize=0 : dialog "Unicodeへの変換が失敗しました" if usize>0 { dialog "文字列("+s+")をUnicodeに変換しました(これをセーブします)" bsave "unicode.dat",buf,usize*2 } if all_test : dialog "次へ進みます" : else stop *x5 exist "unicode.dat" if strsize=-1 : goto x4 bload "unicode.dat",uni,strsize buf="" from_uni buf,uni,-1 mblen=stat if mblen=-1 : dialog "エラーが発生しました" if mblen=0 : dialog "Multibyteへの変換が失敗しました" if mblen>0 : dialog "Multibyteへ変換したもの("+buf+")" if all_test : dialog "次へ進みます" : else stop *x6 #include "treebox.as" cls objsize 200,20 if all_test : button "次へ進みます",*x7 style=1|2|4|$20;|$1000 ;styleについてはtreebox.as参照 treebox 300,200,style ;変数tree_idにtreeboxのIDが入る tree_id=stat ;(HSPのボタンなどのIDとは違う意味を持つ) ;消去するときは _clrobj tree_id treeadd 0, "test1" ;tree_idに親無しのアイテムを作る。 itm0=stat treeadd 0, "test2" itm1=stat repeat 10 treeadd itm0, "test1`s child "+cnt ;親をitm0にする loop if all_test : treeadd itm0, "test1`s child (goto next)" : gt_nxt=stat mes "tree view↑" _objsel tree_id ;treeboxを選択状態にする ;(_objselはHSPのオブジェクトにも使えます) button "add child itm",add_child_itm button "del itm",del_itm button "sort itm",sort_itm *x6_lp wait 10 treeget itm if itm=gt_nxt : goto x7 goto x6_lp *del_itm treeget itm ;選択されているアイテムのIDを取得 treeget txt,6,itm ;itmのテキストを取得 itm_val=stat ;itmが持つ値 treedel itm treemax max mes txt+"を消去しました itemが持つ値:"+itm_val+" (残りアイテム:"+max+"個)" _objsel tree_id goto x6_lp *add_child_itm rnd x,1000 gettime sec,6 treeget itm ;選択されているアイテムのIDを取得 treeadd itm,"new item"+x,,,,sec ;親を選択されているアイテムにする ;secという値をアイテムに持たせることができる _objsel tree_id goto x6_lp *sort_itm treeget itm ;選択されているアイテムを取得 treesort itm ;選択されているアイテムが持つ子をソート _objsel tree_id goto x6_lp *x7 #include "multiopen.as" s=curdir _cls ;全てのオブジェクトを消去 buf_size=1024*4 info_size=128*4 alloc buf,buf_size ;ファイル名がいくつ入るか分からないので十分なサイズを確保しておく alloc info,info_size info=exedir buf="複数のファイルを開く -test title- デフォルトフォルダを "+info+" に設定" multiopen buf,info,0 ;タイトル、デフォルトフォルダの設定(0を指定して設定) buf=buf_size,info_size ;バッファにbuf,infoのサイズを入れる info="HSP2 スクリプトファイル(*.as)|*.as|テキストファイル(*.txt)|*.txt|全てのファイル|*.*|" multiopen buf,info,1 ;デフォルト拡張子は1番目の'as'(2にすると'txt',3で'*') ret=stat if ret=0 : mes "キャンセルされました" : else if ret>0 { notesel buf notemax mx mes "選択されたファイル数 "+mx wnd=0 repeat mx noteget a,cnt mes a+","+strsize+"byte" if wnd<9 { sdim textbuf,32*1024 bload a,textbuf,32*1024 mesbox textbuf,200,80,1 if csry>300 : pos csrx+200,18 wnd+ if wnd=9 : pos 0,240 } loop pos 200,0 if mx=1 : mes "拡張子は"+info : else mes "フォルダ "+info if ret=2 : mes "read onlyボックスがチェックされています" } if all_test : chdir s : pos 400, 400 : button "次へ", x8 : stop : else stop *x8 #include "scrsvr.as" cls ss_chgpwd if stat=0 : s="パスワードが変更されました" : else s="キャンセルされました" mes s ss_chkpwd ;画面のプロパティで'パスワードによる保護'が ;チェックされている場合のみダイアログが現れる if all_test : dialog "次へ進みます" : else stop *x9 #include "progbox.as" #include "trackbox.as" #include "udbtn.as" cls progbox 300,40 : prog_id=stat progbox 300,40 : prog_id.1=stat trackbox 300,40,$100 : trck_id=stat trackbox 300,40,$100 : trck_id.1=stat trackbox 300,40,$100 : trck_id.2=stat s="" input s,100,30 button "",x10 mes " ↑押すと次へ進みます" udbtn 0,0,4|$20 : ud1_id=stat udset ,0 udbtn 0,0,8|$20 : ud2_id=stat udset ,1 _objsel 1 i=0 *@ wait 10 rnd x,100 i+ : if i>100 : i=0 sel_progbox prog_id : progset sel_progbox prog_id.1 : progset x,1 sel_trackbox trck_id.1 : trackpos x sel_trackbox trck_id.2 : trackpos i goto @b *x10 #include "obj.as" _cls ;全てのオブジェクトを消去 button "click!",_x10 : btn_id=0 button "もう一度",x10 : btn2_id=1 button "次へ",x11 objgray btn2_id ;btn2_idを使用不可にする mes "await時間(数字が小さいほど難しい)" lvl=600 input lvl,40,30 s=0 *@ await lvl getobjsize s,btn_id ;オブジェクトのサイズ取得 ;s.0=幅、s.1=高さ、s.2=x座表、s.3=y座表 rnd s.2,winx ;オブジェクトのx座表を変える rnd s.3,winy ;オブジェクトのy座表を変える resizeobj btn_id,s ;オブジェクトのサイズ&位置変更 ;(ここではサイズは変えていない) goto @b *_x10 mes "great !" objgray btn2_id,1 ;btn2_idを使用可にする stop *x11 #include "console.as" cls console console_color $2B putz "HSPからコンソールへ出力\n何か入力してENTERを押してください\n" console_color $F gets s console_end mes "入力文字="+s if all_test : button "次へ",*x12 stop *x12 #include "ime.as" cls alloc linebuf,1024 alloc buf,1024*32 : buf="へんかんしわすれ\nハンカクモジ\n1234\nakai" mes "変換したい行にカーソルを移動させて行変換を押してください" mesbox buf,winx,winy-120,1 mb_id=0 imeinit ime,mb_id objsize 100,24 button "行変換",line_translate button "選択部分変換",sel_translate if all_test : button "次へ",*x13 stop *line_translate objsel mb_id linesel mb_id,-1 *sel_translate objsel mb_id selget linebuf,mb_id imeopen ime imestr ime,linebuf stop *x13 #include "dragdrop.as" cls if all_test : button "次へ",*x14 alloc buf,1024*64 ;ドラッグ&ドロップされたファイル名を入れる変数 dd_accept buf,a mes "このウィンドウにファイルをドラッグ&ドロップしてください" *@ wait 1 if a { color 255,255,255 boxf 0,40,winx,winy color pos 0,40 mes "ドラッグ&ドロップされたファイル数:"+a mes "ドラッグ&ドロップされたファイル位置 x:"+a.1+" y:"+a.2 mes "ドラッグ&ドロップされたウィンドウID :"+a.3 mes buf a=0 ; aをリセットしてください } goto @b *x14 #include "input.as" cls ;if all_test : button "次へ",*x15 if all_test : button "終了",*x15 mes "方向キーでマウスカーソルを移動できます" mes "SHIFTボタンを押すとマウスの左ボタンを押したことになります" *@ movx=0 : movy=0 getkey a,37 : if a : movx- ;←キー getkey a,38 : if a : movy- ;↑キー getkey a,39 : if a : movx+ ;→キー getkey a,40 : if a : movy+ ;↓キー ;SHIFTが押されたら左ボタンを押す getkey kSHIFT,16 : if kSHIFT : a=$2 : else a=0 mouse_event $1+a, movx, movy ;SHIFTを押すとマウスの左ボタンを押したことになりkが1になる getkey k,1 : if k : pset mousex,mousey ;SHIFTが押されてたら左ボタンを放す if kSHIFT : mouse_event $4 await 1 goto @b *x15