6.1.11 Script coding conventions
JP1/Script uses the following coding conventions:
-
When part of a script (excluding a statement) spans two or more lines, write an underscore (_) as the final character. Put at least one space before the underscore. There is no need to write an underscore, however, when the command arguments are enclosed in parentheses.
Example: When the arguments are enclosed in parentheses:
Command (A,B,C, D,E,F)
Example: When the arguments are not enclosed in parentheses:
Command A,B,C, _ D,E,F
-
Command names must not extend over more than one line.
-
Commands are case-insensitive.
-
The maximum size of a script written as one line is 10,240 bytes. Data exceeding this size is ignored.
-
The maximum size of the character strings written in a script is 1,024 bytes. Data exceeding this size is ignored.
-
Write command arguments in one of the following forms. If writing more than one argument, delimit each argument with a comma or space.
Example: Argument specification (Δ: space):
Command(A) CommandΔ(A) CommandΔA Command(A,B) CommandΔ(A,B) CommandΔAΔB CommandΔA,B
-
When the argument of a command or function is itself a command or function that takes an argument, the arguments of that command or function written as the argument must be enclosed in parentheses.
Example: Argument specification when the argument must be enclosed in parentheses:
Command(Function(A,B,C),D,E) Command Function(A,B,C),D,E Command Function(A,B,C)DΔE
-
When the right or left side of an operator is a command or function that takes an argument, the arguments must be enclosed in parentheses.
Example: M=Command(A,B,C) + Function(D)
When specifying the version of Script Engine for executing a script, the following must be written at the head of each script file, where VVRR is the version and revision of a script engine:
#FileVersion=VVRR
If the version specification is omitted or if a nonexistent version is specified, the script file is executed with the version that was set in the Manager window's Options (Compatibility) dialog box. If this line is omitted, the script file will be executed by the version of the Script Engine set in the Manager window's Options (Compatibility) dialog box. When you create a new script file, you can specify in the Manager's Create New Script File dialog box whether to automatically insert the Script Engine version at the head of the file.
Example: #FileVersion = 0700
The Script Engine version does not need to be the same as the version of the installed JP1/Script program.
You can apply the conventions of the specified version of Script Engine to execute a script file.
For example, if JP1/Script 06-00 that uses Callspt as the Function procedure name is upgraded to 06-71 or a later version, you can execute a script file without any changes if the value of #FileVersion is still 0600. If you change the value of #FileVersion to 0671, the execution result will be invalid.
-
The branch destination written for a GoTo statement, On Error statement, or other control must end with a colon (:).
Example: LabelName:
-
To avoid converting \r, \n, \t, or \\ into the corresponding control code when included in a character string, you must write the following at the head of the script file:
#Option=NOCHANGE
The above line must follow the line #FileVersion=VVRR, if included.
If #Option=NOCHANGE is missing, \r, \n, \t, and \\ will be converted into the corresponding control code. That is, \r will be converted into a CR (carriage return) code, \n into a CR-LF (carriage return and line feed) code, \t into a tab, and \\ into a single backslash (\).
Note that version 0500 and earlier versions of Script Engine change \r, \n, \t, and \\ into the corresponding control codes unconditionally, even if #Option=NOCHANGE is written at the head of the file.
Example 1:
#FileVersion = 0700 #Option = NOCHANGE MessageBox("C:\\WkDir\\Script.SPT")
The above example displays the following string in a message box:
C:\\WkDir\\Script.SPT
Example 2:
#FileVersion = 0700 MessageBox("C:\\WkDir\\Script.SPT")
The above example displays the following string in a message box:
C:\WkDir\Script.SPT
-
In the following commands, an ampersand (&) included in the passed string is not displayed. Instead, the character after the ampersand is underscored.
-
Message command for displaying a message in a window
-
InputBox command for displaying a message and text box title in a dialog box
To display an included ampersand as is, write #Option=NOPREFIX at the head of the script file. If you have already written #Option=NOCHANGE, add the NOPREFIX keyword, delimiting the keywords with a comma as follows:
#Option=NOCHANGE,NOPREFIX
You can specify the two keywords in any order. Write this line immediately below the #FileVersion=VVRR line, if included.
Note that if the Script Engine version is earlier than 0520, a single ampersand will be displayed as an underscore added to the next character, even if you include #Option=NOPREFIX. To display an & character as is, use two ampersands (&&).
Example 1:
#FileVersion = 0700 #Option = NOCHANGE,NOPREFIX Message(Target_DispOn,"Display","Client&Server")
The above code displays the following text in a window:
Client&Server
Example 2:
#FileVersion = 0700 Message(Target_DispOn,"Display","Client&Server")
The above code displays the following text in a window:
ClientServer
-
-
To display n double quotation marks (") as is, write n*2 double quotation marks in the string passed to the command.
Example:
MessageBox("Error code:""99""")
The above code displays the following text in a message box:
Error code:"99"