6.1.11 コーディング規則
JP1/Scriptのコーディング規則を次に示します。
-
1文(ステートメントを除く)が複数行にわたるときは,アンダースコア(_)を文の最後に記述します。アンダースコアは,前に1個以上の半角スペースを入れてから記述します。なお,引数を伴うコマンド文で引数を括弧で囲んである場合は,アンダースコアを記述する必要はありません。
(例)引数を括弧で囲む場合
Command (A,B,C, D,E,F)
(例)引数を括弧で囲まない場合
Command A,B,C, _ D,E,F
-
コマンド名を,複数行にわたって記述することはできません。
-
コマンドの大文字と小文字は区別されません。
-
1行に記述できるスクリプトは最大10,240バイトです。10,240バイトを超えた部分のスクリプトは無視されます。
-
スクリプトに記述できる文字列は最大1,024バイトです。1,024バイトを超えた部分のスクリプトは無視されます。
-
コマンドの引数の記述は,以下の形式のうちのどれかで記述します。引数が複数個存在する場合は,「,」(コンマ),またはスペースで区切ります。
(例)引数の記述(△:スペース)
Command(A) Command△(A) Command△A Command(A,B) Command△(A,B) Command△A△B Command△A,B
-
コマンド,または関数の引数に,引数を伴うコマンド,または関数を記述する場合には,引数として記述したコマンド,または関数の引数を,必ず括弧で囲まなくてはなりません。
(例)必ず括弧で囲む場合の記述
Command( Function( A,B,C),D,E) Command Function( A,B,C),D,E Command Function( A,B,C)D△E
-
演算子の左辺または右辺に,引数を伴うコマンドまたは関数を記述する場合は,引数を必ず括弧で囲まなくてはなりません。
(例)M=Command(A,B,C)+Function(D)
-
スクリプトを実行させるスクリプトエンジンのバージョンを指定するときには,各スクリプトファイルの先頭に,#FileVersion=VVRR(VV:JP1/Scriptのバージョン,RR:JP1/Scriptのリビジョン)と記述しなければなりません。この記述がない場合,または存在しないバージョンが指定された場合は,マネージャウィンドウの[オプション(互換性情報)の設定]ダイアログで設定されたバージョンで,スクリプトファイルが実行されます。なお,新規にスクリプトファイルを作成するときには,先頭にスクリプトエンジンのバージョンを自動的に挿入するかどうかを,マネージャウィンドウの[新規作成]ダイアログで指定できます。
(例)#FileVersion = 0700
また,スクリプトエンジンのバージョンは,インストールされているJP1/Scriptのバージョンと同じである必要はありません。
指定したスクリプトエンジンのバージョンの文法規則を適用して,スクリプトファイルを実行できます。
例えば,JP1/Scriptのバージョンが06-00で"Callspt"をFunctionプロシージャ名として使用していた場合,06-71以降へバージョンアップしても#FileVersionが「0600」のままであれば,スクリプトファイルは変更しないで実行できます。#FileVersionを「0671」へ変更すると,実行結果が不正となります。
-
GoTo文やOn Error文などの制御の分岐先は,ラベル名の直後にコロン(:)を付加したものを指定しなければなりません。
(例)LabelName:
-
文字列中に含まれる"\r","\n","\t","\\"をそれぞれ対応するコントロールコードに変換しない場合は,スクリプトファイルの先頭に,#Option = NOCHANGEと記述しなければなりません(ただし,#FileVersion = VVRRが指定されている場合はその下の行に記述しなければなりません)。この記述がない場合には文字列中に含まれる"\r","\n","\t","\\"はそれぞれ対応するコントロールコードに変換されます。("\r"は復帰,"\n"は改行と復帰,"\t"はタブ,"\\"は一つの"\"に変換)
なお,#Option = NOCHANGEの記述があっても,スクリプトエンジンの実行バージョンが0500以前のものであれば,無条件に文字列中に含まれる"\r","\n","\t","\\"をそれぞれ対応するコントロールコードに変換します。
(例)
#FileVersion = 0700 #Option = NOCHANGE MessageBox( "C:\\WkDir\\Script.SPT" ) [メッセージボックスに出力される文字列] C:\\WkDir\\Script.SPT
(例)
#FileVersion = 0700 MessageBox( "C:\\WkDir\\Script.SPT" ) [メッセージボックスに出力される文字列] C:\WkDir\Script.SPT
-
次のコマンドの場合,文字列中に含まれる"&"文字は表示されないでその次の文字が下線付きで表示されます。文字列中に含まれる"&"文字をそのまま表示させる場合は,スクリプトファイルの先頭に,#Option = NOPREFIXと記述してください。#Option = NOCHANGEの記述がある場合は,#Option = NOCHANGE,NOPREFIXとコンマで区切って指定します。(指定は順不同です。ただし,#FileVersion = VVRRが指定されている場合はその下の行に記述してください。)
-
Messageコマンドでウィンドウ出力の場合のメッセージ
-
InputBoxコマンドでメッセージとテキストボックスのキャプション
なお,スクリプトエンジンの実行バージョンが0520より前のものである場合,#Option = NOPREFIXの記述があるときでも,文字列中に含まれる"&"文字は表示されないでその次の文字が下線付きで表示されます。"&"文字を表示する場合は"&&"のように記述してください。
(例)
#FileVersion = 0700 #Option = NOCHANGE,NOPREFIX Message( Target_DispOn,"Display","Client&Server" ) [ウィンドウに出力される文字列] Client&Server
(例)
#FileVersion = 0700 Message( Target_DispOn,"Display","Client&Server" ) [ウィンドウに出力される文字列] ClientServer
-
-
n個のダブルクォーテーション(")を文字としてそのまま表す場合は,文字列中に(n*2)個のダブルクォーテーションを指定します。
(例)
MessageBox( "Error code:""99""" ) [メッセージボックスに出力される文字列] Error code:"99"