Skip to content

Script-IV Tips and Techniques

Script-IV provides advanced data handling features. This section contains the following:

  • Terminal Keyboard Values describes how to manage certain types of data generated by Script-IV.
  • Escape Processing describes how to use the Escape key to interrupt script execution.
  • Using Keys describes how to use KEY references with secondary keys and with numeric and date keys.
  • CONNECT Commands describes how to use CONNECT commands.
  • Database Maintenance and Script-IV provides a list of features exclusive to database maintenance.
  • Interface to Thoroughbred Basic describes the interface between Script-IV and the Thoroughbred Basic third generation language.

The Script-IV TERM-KEY variable enables you to:

  • specify actions that will be taken when a function key is pressed.
  • keep track of which key was last pressed during script execution.
  • set a time-out value for data entry.

For more information on the TERM-KEY variable see the description in the Script-IV Language Reference.

Normal script execution can be interrupted by pressing the Escape key. Most terminals provide an Escape key or a keystroke sequence that performs the escape function. The script specifies how the escape will be processed. There are two ways of handling escape processing in Thoroughbred Script-IV:

  • Standard escape processing, which is controlled by the ESCAPE variable
  • Custom escape processing, which is controlled by the ESCAPE-KEY command

The operator presses the Escape key during script execution. The following message is displayed:

Terminate (Y/N)?

Standard escape processing means that the operator can choose to halt the script or continue script execution. If standard escape processing is disabled, pressing the Escape key will have no effect and the script will continue to execute. You can enable or disable standard escape processing by setting the value of the ESCAPE variable in the script.

Setting the ESCAPE variable to “Y” enables the standard escape procedure:

LET ESCAPE = "Y"

Setting the ESCAPE variable to “N” disables the standard escape procedure:

LET ESCAPE = "N"

The standard processing procedure checks the value of this variable to see if it is enabled. If the ESCAPE variable is not set in a script, the default is Y, and standard escape processing is enabled. For more information on the ESCAPE variable see the Script-IV Language Reference.

The ESCAPE-KEY command provides the ability to design custom escape processing. The command syntax is ESCAPE-KEY procedure**|OFF|ON**.

ESCAPE-KEY procedure
This ESCAPE-KEY command specifies a procedure to execute when the Escape key is pressed. This command overrides the value of the ESCAPE variable and disables standard escape processing. The ESCAPE-KEY procedure command also replaces any previous custom escape processing set in the script.
ESCAPE KEY OFF
This command turns off custom escape processing. The standard escape processing procedure is enabled.
ESCAPE-KEY ON
This command reactivates the last specified custom escape processing procedure. If the script did not previously specify a custom escape processing procedure, this command is ignored.

In primary and continuation scripts, the ESCAPE-KEY command can be used multiple times. The custom escape processing set with the ESCAPE-KEY command overrides any previously defined custom processing.

In public and overlay scripts, only one custom escape procedure should be specified. If multiple ESCAPE-KEY commands are used, the last one encountered by the compiler is the only one executed.

For more information on the ESCAPE-KEY command see the Script-IV Language Reference.

This section describes how to use KEY references with the following types of keys:

  • Secondary Keys
  • Numeric and Date Keys

When you use a KEY reference with secondary keys more than one match is possible. Because of this, when a processing procedure is specified all records that match the specified key will be processed. If no processing procedure is specified only the first match will be read.

Please consider the following examples:

READ link-name USING SORT n IS key-value
READ link-name USING SORT n IS NEXT

This example returns one record beyond the record where the closest match with key-value occurred.

READ link-name USING KEY SORT n IS key-value
PROCESSING IS your-process

This example processes all records that match the key-value.

READ link-name USING KEY SORT n IS key-value

This example only processes the first record that matches the key-value.

Note: The SORT option specifies a sort definition that can be used to access the records in the file by a secondary key. When a SORT option is used, a string value must be specified and the MISSING KEY procedure is not valid. File access using a secondary key will access the record closest to the specified key. A record will always be accessed unless an end of file is reached. For more information see the description of the READ command in the Script-IV Language Reference.

Note: The following information applies to date fields because they are numeric fields.

To use Script-IV to perform file input or output using a numeric key, you must manually pad the data in Script-IV so that it matches the specifications in the format.

For example, if the OPLINES format uses a numeric key called SEQ-NUM defined with a length of 4.0 and a padding type of 3 (right justify and zero fill), the following command will pad the data when adding a new record:

ADD OPLINES USING KEY STR( SEQ-NUM :"0000")

The spacing in the syntax of this command is significant.

For multi-part keys, you must pad any part of the key that is a numeric field. For example:

ADD OPLINES USING KEY CUS-CODE + STR( SEQ-NUM :"0000" )

There is an alternative to padding the numeric data every time you use it in a file input or output command. To use a numeric key to maintain a sequence number, such as an invoice number, it may be easier to define an alphanumeric key and manually convert the data to numeric form to increment it for the next sequence number. For example:

LET ALPHA-SEQ-NUM = STR( NUM( ALPHA-SEQ-NUM ) + 1:"0000" )

A valid entry range specified in the format will not validate that only numbers are entered into the alphanumeric sequence number field. For example, if ALPHA-SEQ-NUM has a length of 4 and a valid entries range of 1,0000,9999, an entry of 000Z is accepted as valid (the valid entries range check performs an entire string comparison).

The CONNECT commands enable a script to connect to various object classes defined in Dictionary-IV, such as help, menus, screens, and views. Additionally, CONNECT commands enable scripts to connect to Query-IV queries or Report-IV reports.

The data in the objects and the functional capabilities of each class are available during script execution. Use of CONNECT commands enables developers to focus on data objects and the classes used to define them, which assures data independence and reduces the amount of procedural Script-IV code required to make use of a data object.

The CONNECT commands enable concurrent development of data objects and scripts. They are designed to promote fast, flexible prototyping and development.

This command enables you to connect to a help definition specified in Dictionary-IV and display the help text during script execution.

For more information on the CONNECT HELP command see the Script-IV Language Reference. For more information on how to create a help definition see the Dictionary-IV Developer Guide.

This command enables you to connect to a pop-up menu definition specified in Dictionary-IV and display the menu during script execution.

For more information on the CONNECT MENU command see the Script-IV Language Reference. For more information on how to create a menu definition see the Dictionary-IV Developer Guide.

This command enables you to connect to a Query-IV query, and display or print the query during script execution.

For more information on the CONNECT QUERY command see the Script-IV Language Reference. For more information on how to create a query see the Query-IV Reference Manual.

This command enables you to connect to a Report-IV report, and display or print the report during script execution.

For more information on the CONNECT REPORT command see the Script-IV Language Reference. For more information on how to create a report see the Report-IV Reference Manual.

This command enables you to connect to a screen definition specified in Dictionary-IV, display the screen, and initiate single-record maintenance during script execution.

For more information on the CONNECT SCREEN command see the Script-IV Language Reference. For more information on how to create a screen definition see the Dictionary-IV Developer Guide.

This command enables you to connect to a view definition specified in Dictionary-IV, display the view, and initiate multi-record maintenance during script execution.

For more information on the CONNECT VIEW command see the Script-IV Language Reference. For more information on how to create a view definition see the Dictionary-IV Developer Guide.

The implementation of a feature sometimes depends upon its context, in this case features in Script-IV and Dictionary-IV Database Maintenance. Whether a feature is implemented depends on how useful the feature is and whether the feature has meaning in a given context.

For example, the format security settings for “Add Only” and “Change Only” have meaning in Dictionary-IV Database Maintenance where “add mode” and “change mode” exist. However, these format security settings have no meaning in Script-IV because these features were not implemented in Script-IV.

The following features are implemented for formats in Dictionary-IV Database Maintenance but not in Script-IV:

  • Security: Add Only
  • Security: Change Only
  • Valid Entries: File Lookup Read Option 1
  • Delete Record Value
  • Audit

The following features are implemented for links in Dictionary-IV Database Maintenance but not in Script-IV:

  • Terminal Access
  • Operator Access
  • Password
  • Audit

For more information on these features see the Dictionary-IV User Guide.

Script-IV provides an interface to Thoroughbred Basic language elements and data constructs. This interface adds functionality and flexibility to the Script-IV language by increasing the number of available language elements and by providing more control over certain types of programming details.

This section contains the following:

  • Thoroughbred Basic Files describes how Script-IV can use data files created by Thoroughbred Basic applications.
  • Thoroughbred Basic Programs describes how to execute Thoroughbred Basic programs from scripts.

For more information, please see the Thoroughbred Basic Reference Manual.

Script-IV can access data files created by a Thoroughbred Basic application. To use an existing data file in a script, follow the procedure below:

  1. Define the format definition to be used to access the data record.
  2. Create a link, which references the format and the data file.
  3. Access the file in Dictionary-IV file maintenance to verify that your format and link definitions are correct.
  4. Declare the link in your script.
  5. Open the link in your script.

After you complete this procedure, you can use Script-IV file I/O commands to access the file through the link name. For more information on Thoroughbred Basic data files see the Thoroughbred Basic Reference Manual.

Script-IV can execute Thoroughbred Basic programs. This feature enables you to access existing Thoroughbred Basic applications in Script-IV. For more information on Thoroughbred Basic programs see the Thoroughbred Basic Reference Manual.

Standard Thoroughbred Basic Program

To execute a standard Thoroughbred Basic program from a script you can use the RUN program-name command. From this program, you can use the RUN program-name directive to execute another Thoroughbred Basic program or a primary script or use the CALL program-name directive to execute a Thoroughbred Basic public program.

For more information on the Script-IV RUN command see the Script-IV Language Reference. For more information on the Thoroughbred Basic CALL and RUN directives see the Thoroughbred Basic Reference Manual.

Thoroughbred Basic Public Program

To execute a Thoroughbred Basic public program from a script you can use the CALL program-name command. From this program, you can use the CALL program-name directive to execute another Thoroughbred Basic public program.

For more information on the Script-IV CALL command, see the Script-IV Language Reference. For more information on the Thoroughbred Basic CALL directive, see the Thoroughbred Basic Reference Manual.

Migrating Programs to Scripts

You can migrate a Thoroughbred Basic application to Script-IV in stages by replacing software programs with scripts. Scripts can emulate the appearance of existing software so that the look and feel remains constant during the conversion. After the Thoroughbred Basic application is fully migrated, you can enhance the applications with features inherent in the Dictionary-IV application development system.

From the Script-IV Developer Guide, version 8.9.1. Open this page in the PDF