TYPE

In this section:

How to:

Reference:

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.


Top of page

x
Syntax: How to Use the TYPE Command

The syntax of the TYPE command is

TYPE [ON ddname] "message" [[|] "message"] ... [;]

where:

ON ddname

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:

  • Web-deployed application, the message is written to the webpage currently displayed in the web browser.

    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.

  • Windows-deployed application run from the Maintain Development Environment, the message is written to the Run tab of the Output window.

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.

message

Is the information to be displayed or written. The message must be enclosed in double quotation marks ("). The message can contain:

  • Any literal text.
  • Variables.
  • Horizontal spacing information.
  • Vertical spacing information.

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.


Top of page

x
Reference: Commands Related to TYPE

SAY writes messages to a file or to the server console. Messages can include multiple expressions of all types.


Top of page

x
Including Variables in a Message

You can embed variables in a message by prefixing the variable with a left caret (<). Unless the field name is the last item in the string, it must be followed by a space. Maintain does not include the caret and space in the display. For example:

TYPE "Accepted:  <Indata(Cnt).Fullname";

Top of page

x
Embedding Horizontal Spacing Information

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";

results in:

                   This starts 20 spaces over
Skip         8 spaces within text
Back4 spaces and overwrite

Top of page

x
Embedding Vertical Spacing Information

Lines can be skipped by supplying a left caret (<), 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";

Top of page

x
Coding Multi-Line Message Strings

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:

  1. End the first line with an ending quotation mark, followed by a vertical bar ( | ).
  2. Begin the second line with a quotation mark. For example:
    TYPE "Name: <Employee(Cnt).First_Name" |
    "<Employee(Cnt).Last_Name" |
    "Salary: <Employee(Cnt).Salary";

Top of page

x
Justifying Variables and Truncating Spaces

To either truncate or display trailing spaces within a field, a left caret (<) or a double left caret (<<) may be used respectively. For character fields, the field values are always left justified. For example:

TYPE "*** <Car.Country ***";
TYPE "*** <<Car.Country   ***";

produces:

*** ENGLAND***
*** ENGLAND  ***

For numeric fields, the left caret causes the field values to be left justified, and trailing spaces are truncated. The double left caret causes the field values to be right justified and leading spaces are displayed.

For example

TYPE "*** <Car.Seats ***"
TYPE "*** <<Car.Seats ***"

produces:

*** 4***
***   4***

Top of page

x
Writing Information to a File

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";

WebFOCUS