In this section: |
|
This topic summarizes all Maintain language commands, grouping them by their primary use (such as transferring control or selecting records). Each command and system variable is described in detail later in this chapter.
The basic syntax consists of the commands that start and terminate a Maintain procedure. The commands are:
Initiates the parsing and execution of a Maintain procedure. It is always the first line of the procedure.
Terminates the execution of a Maintain procedure.
The following command defines Maintain functions:
Defines a Maintain function. Maintain functions are also known as cases.
The following command defines a block a code:
Defines a group of commands as a single block and enables you to issue them as a group. You can place a BEGIN block anywhere individual commands can appear.
You can transfer control to another function within the current procedure, as well as to another procedure. (Functions are also known as cases.)
The commands that allow transfer of control are:
Transfers control to another function. When the function finishes, control is returned to the command following PERFORM. (You can also call a function directly, without PERFORM.)
Transfers control to another function or to a special label within the current function. When the function finishes, control does not return. (You can also call a function directly, without GOTO.)
Executes another Maintain procedure.
The CALL command is advantageous because common code can be shared by many developers, which speeds up both development and maintenance time. For example, a generalized error message display procedure could be used by all Maintain developers. After passing a message to the generalized procedure, the procedure would handle message display. The developers do not need to worry about how to display the message, and the error messages always look consistent to the end users. A second advantage to a modular design is that code that is not executed very frequently can be placed in separate programs in order to reduce the size of the system. Reducing the size makes maintenance easier because the code is easier to understand. Furthermore, if the code is not executed, less memory is used.
The following commands run procedures, or prepare them for execution:
Executes a Maintain procedure, and enables you to pass data from the calling procedure.
Compiles a Maintain procedure to increase its execution speed. This command is outside the Maintain language, but is described in this chapter for your convenience.
The difference between COMPILE and MNTCON COMPILE is that COMPILE only works on procedures with file type or ddname FOCEXEC; whereas MNTCON COMPILE works on procedures with file type or ddname FOCEXEC or MAINTAIN.
Executes an uncompiled Maintain procedure. This command is outside the Maintain language, but is described in this chapter for your convenience.
The difference between EX and MNTCON EX is that EX only works on procedures with file type or ddname FOCEXEC, whereas MNTCON EX works on procedures with file type or ddname FOCEXEC or MAINTAIN.
Recompiles a Maintain procedure that had been compiled under an earlier release of Maintain, in order to improve performance. This command is outside the Maintain language, but is described here for your convenience.
Executes a compiled Maintain procedure. This command is outside the Maintain language, but is described in this chapter for your convenience.
The difference between RUN and MNTCON RUN is that RUN works on compiled Maintain and FOCUS procedures, whereas MNTCON RUN only works on compiled Maintain procedures.
You can use the following commands to prevent unauthorized users from viewing the contents of procedure files and Master Files.
Encodes procedure files and Master Files to prevent unauthorized users from viewing their contents. This command is outside the Maintain language, but is described in this chapter for your convenience.
Decodes files that have been encoded using the ENCRYPT command. This command is outside the Maintain language, but is described in this chapter for your convenience.
The following command is responsible for presentation logic:
Displays a form by which end users can read, enter, and edit data, and manipulates control properties. (Controls are also known as Winform objects.)
The following command enables you to define classes:
Defines classes and data type synonyms.
The following commands enable you to create variables:
Creates local and global variables, including objects.
Creates global variables, including global objects. It can also assign values to existing variables.
Maintain enables you to assign values to existing variables using the following command:
Assigns values to existing variables.
Maintain provides several stack commands to manage the contents of stacks. Unless otherwise specified, each command operates on all rows in the stack. The following example copies the contents of the Indata stack to the Outdata stack:
FOR ALL COPY FROM Indata INTO Outdata;
One row or a range of rows may be specified to limit which rows are affected. As an example
FOR 100 COPY FROM Indata(4) INTO Outdata;
copies 100 records of the Indata stack starting from the 4th record and places them into the stack Outdata.
The stack commands are:
Copies data from one stack to another.
Sorts data in a stack.
Initializes a stack.
Defines the columns in a stack.
In addition, there are two variables associated with a stack which can be used to manipulate individual rows or groups of rows in the stack. The stack variables are:
Is the count of the number of rows in the stack.
Is a pointer to the current instance in the stack.
The record selection commands retrieve data from the data source, and change position in the data source.
The commands are:
Starts at the current position and moves forward through the data source. NEXT can retrieve data from one or more rows.
Searches the entire segment for a matching field value. It retrieves an exact match in the data source.
Changes data source position to be at the beginning of the chain.
In addition, there is a system variable that provides a return code for NEXT and MATCH:
Signals the success or failure of a NEXT or MATCH command.
In addition, you can use the following commands to directly interface with a DBMS:
Turns off preliminary database operation checking before an update.
Determines whether prematch checking is on or off.
Passes SQL commands directly to a DBMS.
Retrieves a DBMS return code after an operation.
The conditional commands are:
Issues a command depending on how an expression is evaluated.
Determines the action to take when the prior MATCH command succeeds.
Defines the action to take if the prior MATCH fails.
Defines the action to take if the prior NEXT command succeeds.
Defines the action to take if the prior NEXT fails.
The commands that can be used to control transactions are:
Adds one or more new data source records.
Updates the specified data source fields or columns. Can update one or more records at a time.
Adds new records to the data source and updates existing records.
Deletes one or more records from the data source.
Makes all data source changes since the last COMMIT permanent.
Cancels all data source changes made since the last COMMIT.
In addition, there are several system variables that you can use to determine the success or failure of a data source operation or an entire logical transaction:
Signals the success or failure of a COMMIT or ROLLBACK command.
Signals the success or failure of an INCLUDE, UPDATE, REVISE, or DELETE command.
If an INCLUDE, UPDATE, REVISE, or DELETE command that writes from a stack fails, this returns the number of the row that caused the error.
In addition, you can use the following commands to directly interface with a DBMS:
Turns off preliminary database operation checking before an update.
Determines whether prematch checking is on or off.
Pass SQL commands directly to a DBMS.
Retrieves a DBMS return code after an operation.
You can change the Maintain environment using the following command:
Sets FOCUS parameters.
You can import libraries using the following command:
Imports a library of shared class definitions or functions into a Maintain procedure.
You can write messages to files, consoles, and forms using the following commands:
Writes messages to a file or to the default output device.
Writes messages to a file or a Winform.
Information Builders |