' 紙芝居.vbs '#p.file 拡張子実行 '#l.label ラベル作成/無指定だと改行 '#j.j ラベルジャンプ '#?.yes.no y/nでラベルジャンプ、空欄だと次行へ '#e. 終了 '#i.file 外部テキストファイルのインポート Dim WSH Set WSH=WScript.CreateObject("WScript.Shell") Dim WSE Set WSE=WSH.Environment dim scfile 'シナリオファイル dim msgboxlen '一回に表示する行数 msgboxlen=10 dim viewexe '画像ビューワ viewexe=WSE("cmds") & "\susie\susie.exe" dim sce() '文字列 dim scel() 'ラベル名/行番号 dim sceyn() 'yes.no のジャンプ先 dim fs set FS=CreateObject("Scripting.FileSystemObject") dim CRLF CRLF=chr(13) & chr(10) dim DBQ DBQ=chr(34) redim sce(0) redim scel(0) redim sceyn(0) if wscript.arguments.count<>0 then scfile=wscript.arguments.item(0) load scfile advexe else wsh.regwrite "HKCR\.adv\","advfile" wsh.regwrite "HKCR\.adv\Content Type","text/scriptlet" wsh.regwrite "HKCR\advfile\","adv.vbs シナリオファイル" wsh.regwrite "HKCR\advfile\EditFlags",0,"REG_BINARY" wsh.regwrite "HKCR\advfile\DefaultIcon\","wscript.exe,3" wsh.regwrite "HKCR\advfile\Shell\","" wsh.regwrite "HKCR\advfile\Shell\Open\EditFlags",1,"REG_BINARY" wsh.regwrite "HKCR\advfile\Shell\Open\","&Open" wsh.regwrite "HKCR\advfile\Shell\Open\command\","wscript.exe " & DBQ & Wscript.ScriptFullName & DBQ & " " & DBQ & "%1" & DBQ msgbox "拡張子advを登録しました。" end if set fs=nothing set wsh=nothing wscript.quit sub load(fn) dim ffi,ffi2 dim i,j,s set FFI=FS.OpenTextFile(fn) i=0:j=0 do s=FFI.ReadLine if mid(s,1,1)="#" then select case mid(s,2,1) case "p" addsce(i):i=i+1:j=0 sce(i)=s addsce(i):i=i+1:j=0 case "l" addsce(i):i=i+1:j=0 scel(i)=mid(s,4) case "?","j" sceyn(i)=s addsce(i):i=i+1:j=0 case "i" ' if dir(mid(s,4))="" then ' msgbox "シナリオエラー" & crlf & "インポートファイルがみつかりません。" & crlf & mid(s,4),,"シナリオエラー" ' else set FFI2=fs.opentextfile(mid(s,4)) do s=FFI2.readline if j=msgboxlen then addsce(i):i=i+1:j=0 sce(i)=sce(i) & s & crlf j=j+1 loop until FFI2.atendofstream FFI2.close set FFI2=nothing ' end if case else msgbox "シナリオエラー" & crlf & "行頭に無効な # があります。",,"シナリオエラー" end select else if j=msgboxlen then addsce(i):i=i+1:j=0 sce(i)=sce(i) & s & crlf j=j+1 end if loop until ffi.atendofstream FFI.close set FFI=nothing addsce(i):i=i+1 sce(i)="#e." end sub sub addsce(i2) redim preserve sce(i2+1) redim preserve scel(i2+1) redim preserve sceyn(i2+1) scel(i2+1)=scel(i2) end sub sub advexe() dim i,j,r dim s i=0 do if mid(sce(i),1,1)="#" then select case mid(sce(i),2,1) case "p" wsh.run viewexe & " " & mid(sce(i),4),1,0:' 拡張子実行部 i=i+1 case "e" exit do case else msgbox "シナリオエラー" & crlf & "行頭に無効な # があります。",,"シナリオエラー" end select else if sceyn(i)<>"" then if mid(sceyn(i),2,1)="j" then msgbox sce(i),,scel(i) s=mid(sceyn(i),4) else r=msgbox(sce(i),vbYesNo,scel(i)) j=instr(4,sceyn(i),".") if r=vbYes then s=mid(sceyn(i),4,j-4) else s=mid(sceyn(i),j+1) end if 's はジャンプ先ラベル名 if s="" then i=i+1 else l=ubound(sce) for j=0 to l if scel(j)=s then i=j:exit for next if j=l+1 then msgbox "シナリオエラー" & crlf & "ジャンプ先がありません。",,"シナリオエラー" i=i+1 end if end if else if sce(i)<>"" then msgbox sce(i),,scel(i) i=i+1 end if end if loop end sub