HP-UX SNAplus2 CPI-C Programmer's Guide (June 2003)
Sample CPI-C Transaction Programs
Processing Overview
Chapter 4 319
Processing Overview
The programs presented in this chapter enable you to browse through a
file on another system. The user is presented with a single data block at
a time, in hexadecimal and character format. After each block, a user can
request the next block, request the previous block, or quit.
CSAMPLE1 (the invoking program) sends a file name to CSAMPLE2
(the invoked program). If CSAMPLE2 locates the file, it returns the first
block to CSAMPLE1; otherwise, it deallocates the conversation and ends.
If CSAMPLE1 receives a block, it displays the block on the screen and
waits for the user to enter F for forward, B for backward, or Q for quit. If
the user selects forward or backward, CSAMPLE1 sends the request to
CSAMPLE2 which in turn sends the appropriate block. This process
continues until the user selects the quit option, at which time
CSAMPLE1 deallocates the conversation and both programs end.
If the user asks for the next block and CSAMPLE2 has sent the last one,
CSAMPLE2 wraps to the beginning of file. Similarly, CSAMPLE2 wraps
to send the last block if the user requests the previous one and the first
block is displayed.
Neither program attempts to recover from errors. A bad return code from
CPI-C causes the program to terminate with an explanatory message.