Accessing Files Programmer's Guide (32650-90885)

124 Chapter8
Writing to a File
Writing Messages to the System Console
.
.
The PRINTOP intrinsic transmits a maximum of 56 ASCII characters to the system console.
Longer messages are truncated to 56 characters. For more information about PRINTOP
intrinsic parameters, refer to the MPE/iX Intrinsics Reference Manual.
Writing a message to the system console and requesting a reply
The PRINTOPREPLY intrinsic can be used to transmit a message from an array in your
program to the system console and to request that a reply be returned. The message that
you send must be no longer than 50 characters in length. PRINTOPREPLY can return a
maximum of 31 ASCII characters to your program. For example, a program could ask the
system operator if the line printer contains a certain type of form. If the response is
affirmative, the program could then write information on these forms.
Example 8-5 is an HP Pascal/iX code segment containing a PRINTOPREPLY intrinsic call.
The program is asking the system operator if the line printer device LP contains the correct
forms. The program is requesting that the system operator respond with a simply YES or
NO response. The program takes appropriate action based upon the characters returned in
reply.
Example 8-5. Writing a Message to the System Console and Requesting a Reply
.
.
.
var
message : packed array [1..50] of char; {PRINTOREPLY parameter}
length : shortint; {PRINTOREPLY parameter}
zero : shortint; {PRINTOREPLY parameter}
reply : packed array [1..31] of char; {PRINTOREPLY parameter}
expected_length: shortint; {PRINTOREPLY parameter}
counter
.
.
.
message := 'Does device LP contain the correct forms? [Y/N]';
length := -47 {length of message }
zero := 0;
reply := ' '; {initialize reply }
expected_length := -3 {expected reply Y/YES/N/NO }
PRINTOREPLY ( message, {message sent to system console }
length, {length of message in range 0..50 }
zero, {required, but not used. Set to 0 }
reply {reply returned in this array }
expected_length {length of reply in range 0..31 }
);
.
.
.
The actual length of the System Operator's reply is returned to expected_length. For
more information about PRINTOREPLY intrinsic parameters, refer to the MPE/iX Intrinsics
Reference Manual.