X25AM Programming Manual

PTP Applications
X25AM Programming Manual527201-001
3-71
Programming Example Written in C
IF ERROR THEN CALL COMM^ERROR (ERROR)
ELSE BEGIN
IF (TAG = READ^TAG) THEN BEGIN
CALL COMM^COMPLETE (COUNT);
TERM^BUFF ':=' "? ";
CALL WRITEREAD (TERM^FILE, TERM^BUFF, 1, MAX^TERM^READ);
IF < THEN CALL DEBUG;
END
END;
END
ELSE
CALL DEBUG;
END; ! DO WHILE
EXIT^PROGRAM:
IF (CALL^SENT^FLAG) THEN
CALL CONTROL (COMM^FILE, 12); ! CLEAR THE CALL TO THE REMOTE
SUBDEVICE.
END; ! PROC COMM MAIN
Programming Example Written in C
The following sample application is written in the C programming language for PTP
mode 0.
Those examples are written in a generic, or “pseudo-” code.
About The C Example
This program allows two terminals to send and receive data across a line using mode 0
of the PTP protocol. The program is designed to run on both the called system and the
calling system. There must be an X.25 subdevice on each end for this program to work
in both directions.
To initiate the X.25 connection enter WAIT at the program prompt on one terminal;
enter CALL on the other. Once the program displays a question mark, you may enter
any text up to 80 characters long. The text will be transmitted to the other end and
displayed.
The example program uses standard C library calls and terms where possible. You
may notice methods that are not standard practice for C programming. Since many
NonStop Kernel users are familiar with TAL, some TAL conventions are used to make
Note. To see non-C examples of how to program for the PTP protocol, refer to the preceding
subsections.