Previous | Contents | Index |
Converts character and numeric input to ASCII character strings. (FAO stands for formatted ASCII output.) By specifying formatting instructions, you can use the F$FAO function to convert integer values to character strings, to insert carriage returns and form feeds, to insert text, and so on.
F$FAO (control-string[,argument[,...]])
control-string
Specifies the fixed text of the output string, consisting of text and any number of FAO directives. The control string may be any length. Specify the control string as a character string expression.The F$FAO function uses FAO directives to modify or insert ASCII data into the fixed text in the control string.
Table DCLI-4 lists the FAO directives you can specify in a control string.
argument[,...]
Specifies from 1 to 15 arguments required by the FAO directives used in the control string. Specify the arguments as integer or character string expressions. Table DCLI-4 lists the argument types required by each FAO directive.FAO directives may require one or more arguments. The order of the arguments must correspond exactly with the order of the directives in the control string. In most cases, an error message is not displayed if you misplace an argument.
If you specify an argument whose type (integer or string) does not match that of the corresponding directive, unpredictable results are returned. You can use the F$INTEGER and F$STRING lexical functions to convert arguments to the proper type.
If there are not enough arguments listed, F$FAO continues reading past the end of an argument list. Therefore, always be sure to include enough arguments to satisfy the requirements of all the directives in a control string.
If you specify an invalid parameter for any directive, you may see unexpected errors, which indicate that the command did not succeed. (These errors are passed through to you from the $FAO system service.)
The F$FAO lexical function invokes the $FAO system service to convert character and numeric input to ASCII character strings. (FAO stands for formatted ASCII output.) By specifying formatting instructions, you can use the F$FAO function to convert integer values to character strings, to insert carriage returns and form feeds, to insert text, and so on.Specify an FAO directive using any one of the following formats:
Format Function !DD One directive !n(DD) A directive repeated a specified number of times !lengthDD A directive that places its output in a field of a specified length !n(lengthDD) A directive that is repeated a specified number of times and generates output fields of a specified length The exclamation point (!) indicates that the following character or characters are to be interpreted as an FAO directive. DD represents a 1- or 2-character uppercase code indicating the action that F$FAO is to perform. When specifying repeat counts, n is a decimal value specifying the number of times the directive is to be repeated. The length value is a decimal number that instructs F$FAO to generate an output field of "length" characters.
Repeat counts and output lengths may also be specified by using a number sign (#) in place of absolute numeric value. If you use a number sign, you must specify the numeric value as an integer expression in the corresponding place in the argument list.
When a variable output field is specified with a repeat count, only one length parameter is required, because each output string has the specified length.
The FAO directives are grouped in the following categories:
- Character string insertion
- Zero-filled numeric conversion
- Blank-filled numeric conversion
- Special formatting
- Parameter interpretation
Table DCLI-4 summarizes the FAO directives and shows the required argument types. In addition, the following sections describe output strings from directives that perform character string insertion, zero-filled numeric conversion, and blank-filled numeric conversion.
Note
Two types of directives that are supported by the $FAO system service are not supported by the DCL F$FAO lexical function. These types are:
- Quadword numeric directives (Q, H, and J), which are not supported in DCL because all DCL numeric values are stored and manipulated as longwords.
- String directives other than the !AS directive, which are not supported in DCL because all DCL strings are stored and manipulated by descriptor.
For further information on the $FAO system service directive, see the HP OpenVMS System Services Reference Manual.
Table DCLI-4 Summary of FAO Directives Directive Argument Type Description Character string insertion: !AS String Inserts a character string as is. Zero-filled numeric conversion: !OB Integer Converts a byte to octal notation. !OW Integer Converts a word to octal notation. !OL Integer Converts a longword to octal notation. !XB Integer Converts a byte to hexadecimal notation. !XW Integer Converts a word to hexadecimal notation. !XL Integer Converts a longword to hexadecimal notation. !ZB Integer Converts a byte to decimal notation. !ZW Integer Converts a word to decimal notation. !ZL Integer Converts a longword to decimal notation. Blank-filled numeric conversion: !UB Integer Converts a byte to decimal notation
without adjusting for negative numbers.!UW Integer Converts a word to decimal notation
without adjusting for negative numbers.!UL Integer Converts a longword to decimal notation
without adjusting for negative numbers.!SB Integer Converts a byte to decimal notation
with negative numbers converted properly.!SW Integer Converts a word to decimal notation
with negative numbers converted properly.!SL Integer Converts a longword to decimal notation
with negative numbers converted properly.Special formatting: !/ None Inserts a carriage return and a line feed. !_ None Inserts a tab. !^ None Inserts a form feed. !! None Inserts an exclamation point (!). !%I Integer Converts a longword integer to a named
UIC in the format
[group-identifier,member-identifier].!%S None Inserts an "s" if the most recently
converted number is not 1. (Not recommended for use with multilingual products.)!%U Integer Converts a longword integer to a numeric UIC in the format [g,m], where g is the group number and m is the member number. The directive inserts the brackets and
the comma.!n<...!> None Left-justifies and blank-fills all data
represented by the instructions ... in
fields n characters wide.!n* c None Repeats the character represented
by c for n times.!n%C String Inserts a character string when the most recently evaluated argument has the value n. (Recommended for use with multilingual products.) !%E String Inserts a character string when the value of the most recently evaluated argument does not match any preceding !n%C directives. (Recommended for use with multilingual products.) !%F None Marks the end of a plurals statement. !%T Integer equal to 0 Inserts the current time. !%D Integer equal to 0 Inserts the current date/time. Argument interpretation: !- None Reuses the last argument. !+ None Skips the next argument. Output Strings from Character String Insertion
The !AS directive inserts a character string (specified as an argument for the directive) into the control string. The field length of the character string when it is inserted into the control string defaults to the length of the character string. If the default length is shorter than an explicitly stated field length, the string is left-justified and blank-filled. If the default length is longer than an explicitly stated field length, the string is truncated on the right.
Output Strings from Zero-Filled Numeric Conversion
Directives for zero-filled numeric conversion convert an integer (specified as an argument for the directive) to decimal, octal, or hexadecimal notation. The ASCII representation of the integer is inserted into the control string. Default output field lengths for the converted argument are determined as follows:
- Directives that convert arguments to octal notation return 3 digits for byte conversion, 6 digits for word conversion, and 11 digits for longword conversion. Numbers are right-justified and zero-filled on the left. Explicit-length fields longer than the default are blank-filled on the left. Explicit-length fields shorter than the default are truncated on the left.
- Directives that convert arguments to hexadecimal notation return 2 digits for byte conversion, 4 digits for word conversion, and 8 digits for longword conversion. Numbers are right-justified and zero-filled on the left. Explicit-length fields longer than the default are blank-filled on the left. Explicit-length fields shorter than the default are truncated on the left.
- Directives that convert arguments to decimal notation return the required number of characters for the decimal number. Explicit-length fields longer than the default are zero-filled on the left. If an explicit-length field is shorter than the number of characters required for the decimal number, the output field is completely filled with asterisks (*).
For byte conversion, only the low-order 8 bits of the binary representation of the argument are used. For word conversion, only the low-order 16 bits of the binary representation of the argument are used. For longword conversion, the entire 32-bit binary representation of the argument is used.
Output Strings from Blank-Filled Numeric Conversion
Directives for blank-filled numeric conversion convert an integer (specified as an argument for the directive) to decimal notation. These directives can convert the integer as a signed or unsigned number. The ASCII representation of the integer is inserted into the control string.
Output field lengths for the converted argument default to the required number of characters. Values shorter than explicit-length fields are right-justified and blank-filled; values longer than explicit-length fields cause the field to be filled with asterisks.
For byte conversion, only the low-order 8 bits of the binary representation of the argument are used. For word conversion, only the low-order 16 bits of the binary representation of the argument are used. For longword conversion, the entire 32-bit binary representation of the argument is used.
Output Strings from Special Formatting Directives
The !n%C and !%E directives insert an ASCII string (based on the value of the most recently evaluated argument) into the output string. These directives are useful for inserting irregular plural nouns and verbs.
If the most recently evaluated argument equals n, the text between one directive and the next is inserted into the output string. If the most recently evaluated argument does not equal n, the next !n%C directive is processed.
If n must be a negative number, you must specify it as an argument and use the number sign (#).
You can specify the !n%C and !%E directives with repeat counts. If you specify repeat counts, the text between one directive and the next is copied to the output string the specified number of times.
The %F directive marks the end of a plurals statement.
#1 |
---|
$ COUNT = 57 $ REPORT = F$FAO("NUMBER OF FORMS = !SL",COUNT) $ SHOW SYMBOL REPORT REPORT = "NUMBER OF FORMS = 57" |
In this command procedure, the FAO directive !SL is used in a control string to convert the number equated to the symbol COUNT to a character string. The converted string is inserted into the control string.
Note that COUNT is assigned an integer value of 57. The F$FAO function returns the ASCII string, "NUMBER OF FORMS = 57", and assigns the string to the symbol REPORT.
#2 |
---|
$ A = "ERR" $ B = "IS" $ C = "HUM" $ D = "AN" $ PHRASE = F$FAO("TO !3(AS)",A,B,C+D) $ SHOW SYMBOL PHRASE $ PHRASE = "TO ERRISHUMAN" |
In this command procedure, the !AS directive is used to insert the values assigned to the symbols A, B, C, and D into the control string.
Because the specified repeat count for the !AS directive is 3, F$FAO looks for three arguments. The arguments in this example include the symbol A ("ERR"), the symbol B ("IS"), and the expression C+D ("HUMAN"). Note that the values of these string arguments are concatenated to form the string "ERRISHUMAN".
#3 |
---|
$ A = "ERR" $ B = "IS" $ C = "HUMAN" $ PHRASE = F$FAO("TO !#(#AS)",3,6,A,B,C) $ SHOW SYMBOL PHRASE $ PHRASE = "TO ERR IS HUMAN " |
In this command procedure, the F$FAO function is used with the !AS directive to format a character string. The first number sign (#) represents the repeat count given by the first argument, 3. The second number sign represents the field size given by the second argument, 6. The next three arguments (A,B,C) provide the strings that are placed into the control string each time the !AS directive is repeated.
Each argument string is output to a field having a length of 6 characters. Because each string is less than 6 characters, each field is left-justified and padded with blank spaces. The resulting string is assigned to the symbol PHRASE.
#4 |
---|
$ OFFSPRING = 1 $ REPORT = F$FAO- ("There !0UL!1%Cis!%Eare!%F !-!UL !-!0UL!1%Cchild!%Echildren!%F here",OFFSPRING) $ SHOW SYMBOL REPORT $ REPORT ="There is 1 child here" |
In this command procedure, the !0UL directive evaluates the argument OFFSPRING but does not insert the value in the output string. The !n%C directive inserts the character string "is" into the output string because its value and the value of the argument OFFSPRING match. The directives !-!UL evaluate the argument a second time so that the correct character string can be inserted in the proper place in the output string. The !%F directive marks the end of each plurals statement. The F$FAO function returns the ASCII string "There is 1 child here" and assigns the string to the symbol REPORT.
Previous | Next | Contents | Index |