Natural ISPF Editor: macros to collapse/expand subroutines

Here are some nice code snippets that can be used with the Natural ISPF “play” command:

To collapse the whole source code except subroutine headers:

x all             
f 'define' w all  
x 'printer' w all 
x 'work' w all    
x 'window' w all  
x 'class' w all   
x 'end-' all      

To expand the subroutine the cursor is on:

:t;label .sbeg                      
f 'END-SUBROUTINE' w;:t             
label .send                         
f 'END-DEFINE' w .sbeg .send prev;:t
label .send                         
x all                               
inc .sbeg .send all                 
top                                 

Save this code as e.g. “expand” and “collapse” in your natural library (as text members). Then assign these text members to PF-Keys, e.g.
PF15: play collapse
PF16: play expand

If you are in the editor, press the PF15 key (in my terminal emulation shift-F3) and the source code will collapse and only the lines containing DEFINE SUBROUTINE and DEFINE DATA are shown. Then point to the desired subroutine and press PF16 (shift-F4). The subroutine will be expanded. You can repeat this as you need (PF15/PF16). To reset the display to the entire code enter “RESET” in the command line.

I tried using the same and i am getting the message as PLAY does not exist in library.:?

“play” is not a Natural command but a Natural ISPF command. You have to start Natural ISPF first (Natural command: SPF).

The macros do not work with the “normal” editors, but only with the Natural ISPF editor.

If you do not have Natural ISPF, you can’t use the macros.

Hi there,

I have used “play” as a Natural ISPF command after using Natural command: SPF, it worked fine. :slight_smile: