Different Types of Scripts
You must specify the script type when you define the script. You can select one of several different types: primary, continuation, overlay, API pre/post processing, file maintenance pre/post processing, copy, public, and utility.
The type of script determines how the script is compiled. This affects the command used to start the script, the script data environment, what will happen when the script terminates, and other execution characteristics.
In this section’s description of script types, the following terms are used:
- Script-IV Data Environment
- The sequence and type of declared data and open message dictionaries that are shared by a script set. Declared data can include links, screens, views, formats, and local data names but not elastic variables or arrays.
- 3GL Data Environment
- Elastic variables and arrays.
- Parent Script
- A primary script that is a starting point for execution of a script set. The parent script contains the initial data declarations that are common to the script set.
- Script Set
- A script or group of related scripts that share a common parent and Script-IV data environment.
- Executing Script
- A script that uses the RUN command to execute another script.
Type S – Script Method
Section titled “Type S – Script Method”A Script-IV Method written specifically for OPENworkshop. This type is preferred over Type 1. For more information, please refer to the OPENworkshop manual.
Type 1 - Primary Script
Section titled “Type 1 - Primary Script”The primary script is used as a starting point for processing. You can execute this script from:
- Any Dictionary-IV menu definition using the type “P”.
- An Dictionary-IV menu, using the /script-name command.
- Another script, using the RUN script-name command.
- A 3GL program or Thoroughbred Basic Console Mode, using the RUN program-name directive.
This script automatically clears the screen at the beginning of execution and initializes the Script-IV and 3GL data environments. It closes all files and clears all variables, replaces any other program in memory, and automatically passes data to certain other script types. When it terminates, execution returns to the last selected Dictionary-IV menu.
Type 2 - Continuation Script
Section titled “Type 2 - Continuation Script”This script serves as the continuation of a primary script or another continuation script.
You can execute this script from a primary or continuation script using the RUN script-name command. This script keeps all files open, retains the values contained in variables, replaces the current primary or continuation script in memory, accepts data from a primary or continuation script, and passes data to certain other script types. When it terminates, execution returns to the last selected Dictionary-IV menu.
The Script-IV data environment is shared with the parent script and script set. It must be declared in the continuation script using the same sequence and type of data as the parent script. You can create a copy module containing the data declarations and use the INCLUDE command to incorporate them into any script.
The 3GL data environment is shared with the parent script.
Type 3 - Overlay Script
Section titled “Type 3 - Overlay Script”This script serves as an overlay to a primary, continuation, or another overlay script. It is a specialized type of continuation script that conserves memory and functions somewhat differently from a continuation script.
You can execute an overlay script from a primary, continuation, or overlay script using the RUN OVERLAY script-name command. The overlay script accepts the entire 4GL environment from the parent script and returns the environment to the parent script. This script operates in its own memory segment. When it terminates, execution returns to the executing script at the command following the RUN OVERLAY command.
The Script-IV data environment is shared with the parent script and script set. It must be declared in the overlay script using the same sequence and type of data as the executing script. You can create a copy module containing the data declarations and use the INCLUDE command to incorporate them into any script.
This script provides an independent 3GL data environment, which can include variables and numeric arrays, which is not affected by and does not affect the 3GL data in the executing script.
The RUN script-name command is not allowed in an overlay script. However, you can use the RUN PUBLIC script-name and RUN OVERLAY script-name commands.
Only one ESCAPE-KEY procedure command can be specified in an overlay script.
Type P - API Pre/Post Processing Script
Section titled “Type P - API Pre/Post Processing Script”This script type can be executed before or after a field is entered in file maintenance. It is designed to be executed from the 8INPUT API, the CONNECT SCREEN command, or the CONNECT VIEW command. The script name is specified in the pre-process or post-processing attribute of a data element in a format definition.
This script is invoked from file maintenance. It cannot be invoked from another script or by the INPUT SCREEN command.
As an example, you can use this script type to calculate sets of numbers before a user performs data entry or use this script type to calculate sets of numbers after a user performs data entry.
When you specify the script name in the pre/post-processing attribute in the format definition, the program execution indicator (exec-indicator) must be 0 (CALL). If you specify a value for string-value, it will be contained in the VAV$ variable, which is described below.
The script must contain the data declaration for the screen definition as the first line in the script. For Dictionary-IV database maintenance, you must use a custom screen definition rather than the default screen.
- Following
- is a list of 3GL variables used by an API Pre/Post Processing Script:
- VAV$
- contains the string value defined in the Pre/Post processing definition.
- SPARM$[ALL]
- is the screen array.
- FPARM$[ALL]
- is the format array.
- FD$
- is the entire data record (before field edit).
- ]7$
- is reserved for system use.
- W1$
- contains the field entry, which contains the entered data.
- SE
- is the field control value.
- W$
- is reserved for system use.
For more information on these variables see the on-line documentation under API Services, 8INPUT, Pre/Post Proc. For more information on the pre/post processing section of a format see the Formats section of the Dictionary-IV Developer Guide
Although this script type was designed to be executed from the 8INPUT API, the CONNECT SCREEN command, or the CONNECT VIEW command, it can also be executed from single-record maintenance (SRM) or multi-record maintenance (MRM). For information on a script type designed to be executed from SRM or MRM, please refer to the following section.
Type 4 - File Maintenance Pre/Post Processing Script
Section titled “Type 4 - File Maintenance Pre/Post Processing Script”This script type can be executed before or after a field is entered in file maintenance. It is designed to be executed from single record maintenance (SRM) or multi-record maintenance (MRM). The script name is specified in the pre-process or post-processing attribute of a data element in a format definition.
This script is invoked from file maintenance. It cannot be invoked from another script or by the INPUT SCREEN command.
As an example, you can use this script type to calculate sets of numbers before a user performs data entry or use this script type to calculate sets of numbers after a user performs data entry.
When you specify the script name in the pre/post-processing attribute in the format definition, the program execution indicator (exec-indicator) must be 0 (CALL). If you specify a value for string-value, it will be contained in the S8$ variable, which is described below.
The script must contain the data declaration for the screen definition as the first line in the script. For Dictionary-IV database maintenance, you must use a custom screen definition rather than the default screen.
- Following
- is a list of 3GL variables used by a File Maintenance Script:
- S8$
- contains the string value defined in the Pre/Post processing definition.
- E1$
- is reserved for system use.
- A8$
- is the screen attribute entry for the current data element:
1,1 Screen column (binary)
2,1 Screen line (binary)
3,1 Screen entry length (binary)
4,1 Fixed attribute entry number (binary)
- V9
- is the current screen attribute table entry number.
- F3$
- contains data name contents before input.
- F4$
- contains data name contents after input. If you want to automatically generate the data field contents before input, using preprocessing procedures sets the contents of this variable, and, when returned to maintenance, the contents will automatically be displayed.
- C
- is the Terminal Control Value (CTL).
- S$
- contains the data record read for File Lookup.
For more information on these variables see the on-line documentation from the pre-process or post-processing attribute field of a data element in a format definition. For more information on the pre/post processing section of a format see the Formats section of the Dictionary-IV Developer Guide.
Although this script type was designed to be executed from single-record maintenance or multi-record maintenance, it can also be executed from the 8INPUT API, the CONNECT SCREEN command, or the CONNECT VIEW command. For information on a script type designed to be executed from the 8INPUT API or the CONNECT commands, please refer to the preceding section on the API Pre/Post Processing Script.
Type 5 - Copy Script
Section titled “Type 5 - Copy Script”This script is not executed or compiled by itself. A copy script is a script fragment that can contain
common groups of directives, functions, or a data environment. Other scripts can use the INCLUDE command to copy this information, which becomes part of that script at compile time. By placing
common code in one location, copy scripts help you avoid duplication and make application maintenance easier.
Type 6 - Public Script
Section titled “Type 6 - Public Script”This script serves as an independent subroutine to a primary, continuation, overlay, or another public script. Having an independent data environment, the public script does not belong to a script set or have a parent script.
You can execute a public script from a primary, continuation, overlay, or public script using the RUN PUBLIC script-name command. Public scripts do not automatically pass any data and operate with an entirely independent data environment. A public script only knows what is explicitly passed to it and what it declared within it. When it terminates, execution returns to the executing script at the command following the RUN PUBLIC command.
This script provides an independent Script-IV data environment that is not affected by and does not affect the data environment in the executing script, but values can be passed to and returned from a public script.
A public script must contain the ENTER PUBLIC command as the first command line in the script after the data declaration. The 3GL data environment is initialized for a public script, except for the variables received through the ENTER PUBLIC command.
The RUN script-name command is not allowed in a public script. However, you can use the RUN PUBLIC script-name command.
Only one ESCAPE-KEY procedure command can be specified in a public script.
Type U - Utility Script
Section titled “Type U - Utility Script”This script is like a primary script except that it does not automatically clear the screen at the beginning of execution and it does not initialize the Script-IV or 3GL data environments. When it terminates, execution returns to the last selected Dictionary-IV menu.
From the Script-IV Developer Guide, version 8.9.1. Open this page in the PDF