Guardian Programmer's Guide

Table Of Contents
Formatting and Manipulating Character Data
Guardian Programmer’s Guide 421922-014
19 - 27
List-Directed Formatting
In addition to the value-separation characters described earlier, you also need to be
aware of the following rules and special values:
Data to be saved as character strings must be enclosed in single quotation marks
in the input buffer; otherwise, the FORMATDATA[X] procedure will return error 272
(illegal input character). Any other special characters, such as spaces, commas,
slashes, and asterisks, can appear in the string. For example:
'This is a string'
You can specify repeated data items in the input buffers using the asterisk (*)
character. For example, to repeat the number 57 ten times, you would put the
following in the input buffer:
10*57
To repeat a string of characters:
5*'TANDEM'
You can specify a null value by placing two consecutive commas in the input buffer,
optionally separated by spaces:
, ,
You can also specify a series of null values with a special use of the * operator.
The following example specifies seven consecutive null values:
7*
A null value has no effect on the corresponding data item.
FORMATDATA[X] converts the data value as specified by the data type and places the
converted value in the variable indicated by the data pointer in the data descriptor.
Sample Program: Formatting List-Directed Input
The following sample program formats input using a list of data descriptors. The
program prompts the user for input, converts the input to internal format, and then
stores the converted form.
Specifically, the code prompts the user twice: once to enter a date and once to enter a
na
me. The user responds to the first prompt by entering the month, day of the month,
and year. The user can enter this information in free format, separating each value
from the next either by a comma or by one or more spaces. Note that the value
representing the month is a character string and must therefore be enclosed in single
quotation marks. For example:
Enter 'month' date year:
'May' 3 1990
The program puts the input values into the first buffer. Note that because the program
fills the buffer with blanks before reading from the terminal, there is no need for the
user to type a value-separating character after typing the year number.