F$FAO()

From VSI OpenVMS Wiki
Revision as of 05:46, 15 January 2019 by Darya.zelenina (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

F$FAO() converts character and numeric input to ASCII character strings. FAO stands for "formatted ASCII output".

Format

F$FAO (control-string[,argument[,...]])

Control strings tell the system what the resulting string should look like. The full list of control strings is presented below.
Arguments (optional) are variables whose values to be used for the control string directives.

Full list of control strings

Character string insertion

Directive Value Description
!AS None Inserts a character string as is:
$ write sys$output f$fao("Welcome back, !AS","John")
Welcome back, John

Zero-filled numeric conversion

Directive Value Description
!OB None Converts a byte to octal notation:
$ write sys$output f$fao("!OB",9)
011
!OW None Converts a word to octal notation:
$ write sys$output f$fao("!OW",9)
000011
!OL None Converts a longword to octal notation:
$ write sys$output f$fao("!OL",9)
00000000011
!XB None Converts a byte to hexadecimal notation:
$ write sys$output f$fao("!XB",15)
0F
!XW None Converts a word to hexadecimal notation:
$ write sys$output f$fao("!XW",15)
000F
!XL None Converts a longword to hexadecimal notation:
$ write sys$output f$fao("!XL",15)
0000000F
!ZB None Converts a byte to decimal notation:
$ write sys$output f$fao("!ZB",100)
100
$ write sys$output f$fao("!ZB",257)
1
!ZW None Converts a word to decimal notation:
$ write sys$output f$fao("!ZW",257)
257
$ write sys$output f$fao("!ZW",65536)
0
!ZL None Converts a longword to decimal notation:
$ write sys$output f$fao("!ZL",4294967296)
0

Blank-filled numeric conversion

Directive Value Description
!UB Integer Converts a byte to decimal notation without adjusting for negative numbers:
$ write sys$output f$fao("!UB",255)
255
$ write sys$output f$fao("!UB",256)
0
$ write sys$output f$fao("!UB",-1)
255
!UW None Converts a word to decimal notation without adjusting for negative numbers:
$ write sys$output f$fao("!UW",-1)
65535
$ write sys$output f$fao("!UW",65536)
0
!UL None Converts a longword to decimal notation without adjusting for negative numbers:
$ write sys$output f$fao("!UL",4294967296)
0
$ write sys$output f$fao("!UL",-1)
4294967295
!SB None Converts a byte to decimal notation with negative numbers converted properly:
$ write sys$output f$fao("!SB",-1)
-1
$ write sys$output f$fao("!SB",256)
0
$ write sys$output f$fao("!SB",127)
127
$ write sys$output f$fao("!SB",128)
-128
!SW None Converts a word to decimal notation with negative numbers converted properly:
$ write sys$output f$fao("!SW",32000)
32000
$ write sys$output f$fao("!SW",-32000)
-32000
$ write sys$output f$fao("!SW",64000)
-1536
$ write sys$output f$fao("!SW",65537)
1
!SL None Converts a longword to decimal notation with negative numbers converted properly:
$ write sys$output f$fao("!SL",65537)
65537
$ write sys$output f$fao("!SL",4294967294)
-2

Special formatting

Directive Value Description
!/ None Inserts a carriage return and a line feed:
$ write sys$output f$fao("Hello!/Goodbye")
Hello
Goodbye
!_ None Inserts a tab:
$ write sys$output f$fao("Hello!_Goodbye")
Hello   Goodbye
!^ None Inserts a form feed:
$ write sys$output f$fao("Hello!^Goodbye")
Hello















Goodbye
!! None Inserts an exclamation point (!):
$ write sys$output f$fao("Hello!!")
Hello!
$ write sys$output f$fao("Hello!")
%SYSTEM-F-BADPARAM, bad parameter value
 \Hello!\
!%I (as in Irene) None
$ write sys$output f$fao("!%I",65540)
[SYSTEM]
!%S None
$ write sys$output f$fao("I have !SL apple!%S",5)
I have 5 apples
$ write sys$output f$fao("I have !SL apple!%S",1)
I have 1 apple
!%U None
$ write sys$output f$fao("!%U",65540)
[1,4]]
!nx None
$ write sys$output f$fao("!10SL",5)
         5
!n* c None
$ write sys$output f$fao("!5*a")
aaaaa
!n%C None Inserts a character string when the most recently evaluated argument has the value n. (Recommended for use with multilingual products.)
REPORT = F$FAO("There !0UL!1%Cis!%Eare!%F !-!UL !-!0UL!1%Cchild!%Echildren!%F here",OFFSPRING)
!%E None 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.)
REPORT = F$FAO("There !0UL!1%Cis!%Eare!%F !-!UL !-!0UL!1%Cchild!%Echildren!%F here",OFFSPRING)
!%F None Marks the end of a plurals statement.
REPORT = F$FAO("There !0UL!1%Cis!%Eare!%F !-!UL !-!0UL!1%Cchild!%Echildren!%F here",OFFSPRING)
!%T 0 Inserts the current time:
$ write sys$output f$fao("It's !%T",0)
It's 12:54:00.68
!%D 0 Inserts the current date/time:
$ write sys$output f$fao("It's !%D",0)
It's 16-AUG-2018 12:54:08.98

See also