Exchange/SNA Manual
Console Program Example
Example Programs
E–12 104700 Tandem Computers Incorporated
Console Program
Example
This section contains an example Exchange/SNA console application program:
 Page 1 [1] $RJE.EXCHAPPL.CONSRC 1991-05-29 13:38:20
 TAL - T9250C30 - (01DEC90)
 Copyright Tandem Computers Incorporated 1976, 1978, 1981-83, 1985, 1987-90
 2. 000000 0 0 ?NOCODE,NOMAP,NOLMAP,INSPECT,SYMBOLS
 3. 000000 0 0 !****************************************************************************!
 4. 000000 0 0 ! EXCHANGE/SNA CONSOLE APPLICATION EXAMPLE DATE 05/28/91 !
 5. 000000 0 0 ! !
 6. 000000 0 0 ! This console example illustrates how an application program can use !
 7. 000000 0 0 ! Exchange/SNA to send console commands to the host and receive console !
 8. 000000 0 0 ! output from the host. !
 9. 000000 0 0 ! !
 10. 000000 0 0 ! The Exchange/SNA console subdevice can be opened by up to seven programs !
 11. 000000 0 0 ! at once. (Each Exchange/SNA command interpreter counts as one program.) !
 12. 000000 0 0 ! Any program that has opened the console subdevice can use the console !
 13. 000000 0 0 ! subdevice to send console commands to the host. All programs that have !
 14. 000000 0 0 ! opened the console subdevice receive the console output from the host. !
 15. 000000 0 0 ! The console subdevice is a single logical device, regardless of the number !
 16. 000000 0 0 ! of programs that have it open at once, and the host sends its output to !
 17. 000000 0 0 ! this single logical device. The Exchange/SNA line server distributes the !
 18. 000000 0 0 ! console output to all programs that have opened the console subdevice. !
 19. 000000 0 0 ! !
 20. 000000 0 0 ! Any program that opens the console subdevice must maintain an outstanding !
 21. 000000 0 0 ! READ on the console subdevice at all times. There are two reasons for !
 22. 000000 0 0 ! this requirement. One, the program needs to handle unsolicited messages !
 23. 000000 0 0 ! that may arrive from the host. Two, console commands produce a variable !
 24. 000000 0 0 ! number of lines of output, and the program must be prepared to receive an !
 25. 000000 0 0 ! unknown number of lines of output in response to any issued commands. !
 26. 000000 0 0 ! !
 27. 000000 0 0 ! The console subdevice never returns an end-of-file error. !
 28. 000000 0 0 ! !
 29. 000000 0 0 ! The following outlines the function of this example program. !
 30. 000000 0 0 ! !
 31. 000000 0 0 ! Open and read $RECEIVE. !
 32. 000000 0 0 ! Open the home terminal. !
 33. 000000 0 0 ! Open the Exchange/SNA line server console subdevice. !
 34. 000000 0 0 ! Start the main work loop. !
 35. 000000 0 0 ! Post a READ on the console subdevice. !
 36. 000000 0 0 ! Write the prompt to the terminal and post a READ on the terminal. !
 37. 000000 0 0 ! Wait for an I/O to complete. !
 38. 000000 0 0 ! If the terminal read completed, check what was entered. !
 39. 000000 0 0 ! If EXIT was entered, end the main loop and stop. !
 40. 000000 0 0 ! Otherwise, cancel the current console read and send what was !
 41. 000000 0 0 ! entered to the host. !
 42. 000000 0 0 ! If the console read completed, then: !
 43. 000000 0 0 ! Cancel the outstanding read on the terminal. !
 44. 000000 0 0 ! Modify the terminal attributes to write over the prompt. !
 45. 000000 0 0 ! Write the console output to the terminal. !
 46. 000000 0 0 ! Modify the terminal attributes to advance to the next line. !
 47. 000000 0 0 ! Repeat loop until EXIT is entered. !










