Skip to content

Reading the TSO Session Screen

Vector 5:2, page 83

system interfaces programming techniques

Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 83

Hacking the TSO session manager has always had some fun potential (such as the reverse-video pink and white stripes illustrated in an earlier VECTOR). However I have to admit that the function below is actually rather useful!

     R←SNAP PAGES;XX;CTLZAP;DATZAP;SS;CTLSM;IN;FLDS
     ----------------------------------------------

[1]      ⍝GET TSO SESSION SCREEN(S) INTO RESULT VARIABLE.
[2]      ⍝
[3]      ⍝ XX←SNAP 5  GETS LAST 5 SCREENS (LESS TRAILING NULL LINES)
[4]      ⍝
[5]      ⍝∘∘ Saved on 17/10/88 at 14:20 (by 2001)

[6]       XX←126 ⎕SVO 2 6 ⍴'CTLZAPDATZAP' ⋄ XX←120 ⎕SVO 'CTLSM'
[7]       PAGES←1⌈1↑,PAGES
[8]       R← 0 79 ⍴' '

[9]      ⍝ SCROLL BACK TO THE FIRST REQUIRED PAGE ...

[10]      CTLSM←'PAGE -',⍕PAGES-1 ⋄ XX←CTLSM

[11]     ⍝FIND OUT HOW BIG THE SCREEN IS ....

[12]      CTLZAP← 110 14 ⋄ SS←CTLZAP[8]

[13]     ⍝ SELECT GDDM PAGE 1001 ....

[14]      CTLZAP← 305 1001 ⋄ XX←CTLZAP

[15]     ⍝READ ALL FIELDS .....

[16] NEXT:FLDS←(1008+⍳SS-2)
[17]      CTLZAP←,422,FLDS,[1.5] 79 ⋄ XX←CTLZAP
[18]      IN←((SS-2),79)⍴DATZAP

[19]     ⍝ STOP IF WE HIT A SCREEN FULL OF NULLS ...

[20]      →(⎕AV[256]∧.=,IN)↑EXIT
[21]      R←R,[1] IN
[22]      →(0⌈PAGES←PAGES-1)↓EXIT
[23]      CTLSM←'PAGE +1' ⋄ XX←CTLSM ⋄ →NEXT

[24]     ⍝FINALLY DESELECT THIS RATHER DANGEROUS PAGE ....

[25] EXIT:CTLZAP← 305 1 ⋄ XX←CTLZAP
[26]      XX←⎕SVR 2 6 ⍴'CTLZAPDATZAP'

[27]     ⍝ LOSE SPARE LINES AND THE LINE WITH 'SNAP' ON IT ...

[28]      R←((¯1++/∨\⌽R∨.≠⎕AV[256]),79)↑R

[29]     ⍝ TRANSLATE NULLS TO BLANKS ...

[30]      IN←,R ⋄ IN[(IN=⎕AV[256])/⍳⍴IN]←' ' ⋄ R←(⍴R)⍴IN
     ∇

The motivation was as follows. We had just acquired a reasonable APL font for our Xerox 4045 laser. Of course this had the characters in very peculiar places, so a quick ⎕AV lookup was in order. It also needed a few control sequences to select the APL font, set sensible margins and so on.

Now this was fine for function listings, where you already had hold of the data in an APL matrix. Of course it was quite useless for screen hardcopy (of things like traces) unless you could somehow nab the screen contents into a variable. Hence the above listed function.

It will go back as many screens as you ask for (SNAP 999 will end up at the beginning of scrolling memory) and then page forward a screen at a time taking snapshots as it goes. As soon as it hits a completely null screen it assumes (as a safety measure) that it has arrived back at your current screen, and it therefore gives up.

The other interesting use was in creating the basics of a user guide from genuine screen hardcopies. In this case the snapped images were wrapped around with some text and shipped down to the PC for final editing. Have fun.