8.7.1 Menu (display a user-defined menu form)
- Purpose
-
Displays a user-defined window (menu form).
- Syntax
Menu (FormName, [SpnFilePath] [, FocusField])
- Arguments
-
- FormName
-
Specify the form name of the menu as a character string or as a variable that stores this value.
- SpnFilePath
-
Specify the full path of the menu information file that contains information about the menu to be displayed. Specify the path as a character string or as a variable that stores this value.
This value is optional. If you omit this value, the menu information file for the executing script is assumed.
If the script was invoked by the CallSpt command, the menu information file for the called script file is assumed.
- FocusField
-
Specify the field name that has the focus at menu startup. Write the field name as a character string or as a variable that stores this value.
This value is optional. If you omit this value, the field defined in the menu information file has the focus.
- Description
-
The Menu command displays a user-defined menu form. The command returns True on successful execution, or False if an error occurs.
When the menu form ends, one of the following values indicating the reason for termination is stored in the _FORM_TERM_KEY_ reserved variable:
Value
Meaning
Enter
The user pressed the Enter key.
Esc
The user pressed the Esc key.
F1 to F12
The user pressed a function key (F1 to F12).
Command
The user executed a command.
Close
The user pressed Alt + F4 or the Close button.
Timeout
The timeout was exceeded.
When the reason for termination is Command, the number of the executed command is stored in the _FORM_TERM_CMDNO_ reserved variable.
One of the following strings representing the modifier key of the termination key is set in the _FORM_MODIFY_KEY_ reserved variable:
Value
Meaning
Shift
Shift key
Ctrl
Ctrl key
Alt
Alt key
Shift_Ctrl
Shift key and Ctrl key
Ctrl_Alt
Ctrl key and Alt key
Shift_Alt
Shift key and Alt key
Shift_Ctrl _Alt
Shift key and Ctrl key and Alt key
In addition, the name of the field that last had the focus is set in the _FORM_FIELD_NAME_ reserved variable.
- Note
-
You cannot use this command in a script started as a service. An execution error occurs if this command is used.
If the external command executed from the Menu command returns a nonzero value as the termination code, a message box is displayed. To hide this message box, set 0 in the following registry key:
- Registry key
-
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Hitachi\JP1/Script\SPTX
- Value name
-
Menu_EmgMsgBox
- Value datatype
-
REG_DWORD
- Value
-
0: Hide the message box.
1: Display the message box
- When the setting takes effect
-
The setting takes effect the next time the script file is executed.
- Example
' Cancel script execution if the menu terminates because ' the Esc key was pressed. Menu ("MyMenu") If _FORM_TERM_KEY_ = "Esc" Then Exit Else ... ... ... End
- JP1/Script version
-
Supported from JP1/Script 05-20.