[INHERIT('sys$library:starlet', 'sys$library:pascal$lib_routines')] PROGRAM Use_Fao_and_Faol(OUTPUT); VAR I : INTEGER; Status : INTEGER; Control_String : VARYING [64] OF CHAR; Output_Buffer : VARYING [133] OF CHAR; Sentence : VARYING [32] OF CHAR; Parameter_List : ARRAY [1..3] OF INTEGER; BEGIN { Format an integer } I := 2525; Control_String := 'The value of I is !ZL'; { Let $fao make a VARYING OF CHAR by letting it } { write the output into the VARYING's body and } { write the length into the VARYING's length. } { We also use foreign mechanism specifiers for } { the P1 .. Pn parameters since they are } { different for almost every call to $fao. } Status := $fao( Ctrstr := Control_String, Outlen := Output_Buffer.Length, Outbuf := Output_Buffer.Body, P1 := %IMMED I ); IF NOT ODD(Status) THEN LIB$Stop(Status); WRITELN(Output_Buffer); { Format a string } Control_String := 'The magic string is "!AS"'; Status := $fao( Ctrstr := Control_String, Outlen := Output_Buffer.Length, Outbuf := Output_Buffer.Body, P1 := %STDESCR 'VAX PASCAL' ); IF NOT ODD(Status) THEN LIB$Stop(Status); WRITELN(Output_Buffer); { Format a date/time } Control_String := 'The current time and date is !%D'; Status := $fao( Ctrstr := Control_String, Outlen := Output_Buffer.Length, Outbuf := Output_Buffer.Body, P1 := %IMMED 0 ); IF NOT ODD(Status) THEN LIB$Stop(Status); WRITELN(Output_Buffer); { Format with 2 integers } Control_String := 'I = !SL, (I-3) = !SL'; { The definition of $fao in STARLET.PEN } { only contains formal parameter defintions } { for the P1 parameter. By default, this } { makes VAX Pascal believe that there are } { only 4 parameters to $fao. To pass } { additional parameters, we will use a } { foreign mechanism specifier on the actual } { parameter to override the formal parameter} { checking. In order to use this technique } { we must use positional parameter syntax. } Status := $fao( {Ctrstr :=} Control_String, {Outlen :=} Output_Buffer.Length, {Outbuf :=} Output_Buffer.Body, {P1 :=} %IMMED I, {P2 :=} %IMMED (I-3) ); IF NOT ODD(Status) THEN LIB$Stop(Status); WRITELN(Output_Buffer); { Now do some $faol examples } Control_String := 'Time is !%D, I = !SL, (I-3) = !SL'; { Fill in Parameter_List entries } Parameter_List[1] := 0; { System Date/Time } Parameter_List[2] := I; Parameter_List[3] := I-3; Status := $faol( Ctrstr := Control_String, Outlen := Output_Buffer.Length, Outbuf := Output_Buffer.Body, Prmlst := Parameter_List ); IF NOT ODD(Status) THEN LIB$Stop(Status); WRITELN(Output_Buffer); { Print out the current time and a string } Control_String := '!AD!%D'; Sentence := 'The date and time is '; { fill info into Parameter_List } Parameter_List[1] := LENGTH(Sentence); { The length of the string } Parameter_List[2] := IADDRESS(Sentence.Body); { The address of the varying string's body } Parameter_List[3] := 0; { Date/Time } Status := $faol( Ctrstr := Control_String, Outlen := Output_Buffer.Length, Outbuf := Output_Buffer.Body, Prmlst := Parameter_List ); IF NOT ODD(Status) THEN LIB$Stop(Status); WRITELN(Output_Buffer); END.