3270 Data Stream Programming

Hello, World (Version 1)

 

Introduction

Now that we have been through the basics, lets make an attempt at building a data stream to write a simple message to the screen.  We will just write "Hello, World!" out on the screen.

First we need a WCC with "keyboard restore" and "reset MDT" set.  The binary value for the WCC is b'00000011'.  Using the translation table we see our WCC is x'C3'.  We can follow with our SBA command x'11' and then our buffer address.  For this example we will start the field at Row 10, Column 33.  Using our buffer address table we see the buffer code is x'4BF0'.  Next we use the SF command to start a new field.  We set the Protected, Numeric, and Intensified Display attributes.  Using the I/O Code conversion table we get a value of x'F8'.  Here is the data stream we need to send to the terminal:

x'C3114BF0',x'1DF8',C'HELLO, WORLD!'

A TSO Program

We will now write a TSO program to write out our message.  

Assembler Code To Calculate Buffer Addresses

HELLO1   CSECT ,
         SAVE  (14,12),,*
         LR    12,15
         USING HELLO1,12
*
         LA    1,SAVEA
         ST    1,8(,13)
         ST    13,4(,1)
         LR    13,1
*
         STFSMODE ON,INITIAL=YES
         STTMPMD ON
*
         TPUT  STREAM,STREAMLN,FULLSCR
*
         TGET  INBUF,INBUFLN,ASIS
*
         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!'
STREAMLN EQU   *-STREAM
*
INBUF    DS    XL128
INBUFLN  EQU   *-INBUF
*
SAVEA    DS    18F
         END   ,

We need a little extra code to write our data stream using TSO.  First we should tell TSO we are about to write a full screen message by using the STFSMODE and STTMPMD macros.  The INITIAL=YES tells TSO that we are about to issue the first full screen write and there is not need to allow force the user to hit enter as we swap into full screen mode.  We use the same macros when we are done to turn off full screen mode.  We also use the STLINENO macro to tell TSO to start with the first line of the screen.  For now you do not need to worry too much about these macros, you just need to code them this way.

You may also notice we added two extra bytes to the front of our data stream.  These are not part of the data stream but are used by TSO.  The x'27' is the escape character that lets TSO know we are writing our own data stream to the terminal.  The escape character is followed by a channel command code x'F5' which is an Erase/Write command.  This will clear the 3270 buffer prior to loading our data stream.  We could also use a command code of x'F1' to just write to the buffer without first erasing it.  Our 3270 data stream follows these two characters.

To write it out, we use the TPUT macro with the FULLSCR option.  I have followed with a TGET with the ASIS option to wait for the terminal user to hit some action key.

I suggest you try entering this small program, compiling, link editing it and then run it under TSO using the CALL command.  

Next Page