In this section:
The TYPE command writes messages to a file, a web browser, or the Output window of the Maintain Development Environment. The TYPE command is helpful for application debugging, such as tracing application flow-of-control, and for recording an accounting trail. If you wish to display messages to application users, it is recommended that you use forms, which provide superior display capabilities and better control than the TYPE command.
The syntax of the TYPE command is
TYPE [ON ddname] "message" [[|] "message"] ... [;]
Specifies the logical name of the file that the TYPE message is written to when ON is specified. You must define the ddname (using a DYNAM or FILEDEF command) prior to the first usage. The message string can be up to 256 characters in length. The output starts in column 1. In order to append to an existing file or to write to a file from more than one procedure, append to the file by specifying the appropriate option in the DYNAM command.
If ON ddname is omitted, in a:
If the message is written from a procedure that resides on a different server than the webpage, the message is prefixed with (FOC03764) From Server ==> to indicate that it was posted by a remote procedure.
In addition, if ON ddname is omitted and this procedure was called remotely (that is, called using a CALL procname AT command), the message will also be copied to the FocMsg stack of the calling procedure.
Is the information to be displayed or written. The message must be enclosed in double quotation marks ("). The message can contain:
The layout of the message is exactly what is specified.
Terminates the command. Although the semicolon is optional, including it to allow for flexible syntax and better processing is recommended. For more information about the benefits of including the semicolon, see Terminating Command Syntax.
SAY. Writes messages to a file or to the server console. Messages can include multiple expressions of all types.
You can embed variables in a message by prefixing the variable with a left angle bracket (<). Unless the field name is the last item in the string, it must be followed by a space. Maintain does not include the angle bracket and space in the display. For example:
TYPE "Accepted: <Indata(Cnt).Fullname";
TYPE information can be placed in a specific column or can be moved a number of columns away from the current position. The following example
TYPE "<20 This starts 20 spaces over"; TYPE "Skip <+8 8 spaces within text"; TYPE "Back up <-4 4 spaces and overwrite";
This starts 20 spaces over Skip 8 spaces within text Back4 spaces and overwrite
Lines can be skipped by supplying a left angle bracket (<), slash (/) and the number of lines to be advanced. If the line advance specification is at the beginning of the line, the specified number of lines are advanced before the following text.
TYPE "</3 Displays 3 blank lines" | " before this line";
If </number is encountered in the middle of the line, the line feed occurs when </number is encountered.
TYPE "This will </2 leave one" | " blank line before the word leave";
Sometimes, a message string needs to be coded on more than one line of a TYPE command. This can occur if indented TYPE lines, spacing information, or field prefixes extend the message string beyond the end of the line. You can wrap a message string onto the next line of a TYPE command if you:
TYPE "Name: <Employee(Cnt).First_Name" | "<Employee(Cnt).Last_Name" | "Salary: <Employee(Cnt).Salary";
To either truncate or display trailing spaces within a field, a left angle bracket (<) or a double left angle bracket (<<) may be used respectively. For character fields, the field values are always left justified. For example:
TYPE "*** <Car.Country ***"; TYPE "*** <<Car.Country ***";
*** ENGLAND*** *** ENGLAND ***
For numeric fields, the left angle bracket causes the field values to be left justified, and trailing spaces are truncated. The double left angle bracket causes the field values to be right justified and leading spaces are displayed.
TYPE "*** <Car.Seats ***" TYPE "*** <<Car.Seats ***"
*** 4*** *** 4***
You can use TYPE commands to write information to a file. The following example writes every transaction record to a log file:
FOR ALL NEXT Emp_ID Last_Name First_Name INTO Stackemp; COMPUTE Cnt=Cnt+1; TYPE ON TransLog "<Stackemp(Cnt).Emp_ID " | "<Stackemp(Cnt).Last_Name" | "<Stackemp(Cnt).First_Name";
The next example places a message into an errors log file if the salary in the stack is greater than allowed:
IF Stackemp(Cnt).Curr_Sal GT Allowamt THEN TYPE ON ErrsFile "Salary for employee <Stackemp.Emp_ID" | "is greater than is allowed.";
The last example writes three lines to the file NoEmpl if the employee is not in the data source:
MATCH Emp_ID; ON NOMATCH TYPE ON NoEmpl "<Emp_ID" "<Last_Name" "<First_Name";