When we issue the TGET macro with the ASIS parameter specified, TSO will issue a "Read Modified" command to the 3270 terminal. The terminal will respond with (1) an AID or Action ID character that identifies which key was the cause of input to be accepted (Enter, PKxx, PAx, Clear), (2) the location of the cursor when the input key was pressed and (3) fields with the MDT bit set. The fields are returned starting with a x'11' followed by a two byte encoded buffer address followed by the data from the field. By scanning for the special code x'11' we can find the start and end of each data field.
Now we will write a simple assembler program to write out a screen, accept input and then print out the value of the AID and the Cursor position.
AID1 CSECT , SAVE (14,12),,* LR 12,15 USING AID1,12 * LA 1,SAVEA ST 1,8(,13) ST 13,4(,1) LR 13,1 * STFSMODE ON,INITIAL=YES STTMPMD ON * LOOP DS 0H TPUT STREAM,STREAMLN,FULLSCR * TGET INBUF,INBUFLN,ASIS * CLI INBUF,X'F3' IS IT PFK3? BE EXIT * UNPK WORK3,INBUF(2) TR WORK3(2),TRTAB-C'0' MVC AIDCHAR,WORK3 * UNPK WORK5,INBUF+1(3) TR WORK5(4),TRTAB-C'0' MVC CURSOR,WORK5 * MVI SETCSR,X'11' SBA MVC SETCSR+1(2),INBUF+1 CURSOR POSITION MVI SETCSR+3,X'13' IC (INSERT CUROSR) * B LOOP * EXIT DS 0H STLINENO LINE=1 STFSMODE OFF STTMPMD OFF * L 13,4(,13) LM 14,12,12(13) SLR 15,15 BR 14 * STREAM DS 0C DC X'27' ESCAPE CHAR DC X'F5' ERASE/WRITE DC X'C3' WCC DC X'114BF0' SBA DC X'1DF8' SF (PROT,HIGH INTENSITY) DC C'HELLO, WORLD!' DC X'114D40' SBA DC X'1DF8' SF DC C'AID=' AIDCHAR DC C' ' DC X'114E50' SBA DC X'1DF8' SF DC C'CURSOR=' CURSOR DC C' ' SETCSR DC C' ' STREAMLN EQU *-STREAM * INBUF DS XL128 INBUFLN EQU *-INBUF * WORK3 DC XL3'00' WORK5 DC XL5'00' * TRTAB DC C'0123456789ABCDEF' * SAVEA DS 18F END , |
If you key in this program, assemble and link edit it, you can then run it and press different action keys and see what happens. You will notice that if you press the PA1 key that TSO will intercept it and interrupt your program. From looking at the code you can tell that PFK03 has an AID value of x'F3'. We check for this value and use PFK03 to signal us to end the program.
When running the program, you can move the cursor to different positions on the screen before pressing an action key and see how the buffer position changes. You will also note that we use a SBA / IC sequence to always place the cursor back where we found it on input.
60 | No AID |
7D | Enter |
F1-F9 | PF1 - PF9 |
7A-7C | PF10 - PF12 |
C1-C9 | PF13 - PF21 |
4A-4C | PF22 - PF24 |
6C | PA1 |
6E | PA2 |
6B | PA3 |
6D | Clear |