# Natural ISPF Editor: macros to collapse/expand subroutines

**URL:** <https://techcommunity.softwareag.com/t/natural-ispf-editor-macros-to-collapse-expand-subroutines/60627>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-Code-Samples\
**Created:** [March 2, 2006, 10:50pm UTC](https://techcommunity.softwareag.com/t/natural-ispf-editor-macros-to-collapse-expand-subroutines/60627 "2006-03-02T22:50:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wilfried\_B](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wilfried_b/32/83_2.png) [@Wilfried\_B](https://techcommunity.softwareag.com/u/Wilfried_B)\
**Post date:** [March 2, 2006, 10:50pm UTC](https://techcommunity.softwareag.com/t/natural-ispf-editor-macros-to-collapse-expand-subroutines/60627/1 "2006-03-02T22:50:39Z")

</div>

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:

```auto
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:

```auto
: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.

---

<div class="post-metadata">

**Author:** ![ambooj](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@ambooj](https://techcommunity.softwareag.com/u/ambooj)\
**Post date:** [January 3, 2007, 5:01pm UTC](https://techcommunity.softwareag.com/t/natural-ispf-editor-macros-to-collapse-expand-subroutines/60627/2 "2007-01-03T17:01:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Wilfried\_B](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wilfried_b/32/83_2.png) [@Wilfried\_B](https://techcommunity.softwareag.com/u/Wilfried_B)\
**Post date:** [January 8, 2007, 4:01pm UTC](https://techcommunity.softwareag.com/t/natural-ispf-editor-macros-to-collapse-expand-subroutines/60627/3 "2007-01-08T16:01:13Z")

</div>

“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.

---

<div class="post-metadata">

**Author:** ![PepsiCrazy](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@PepsiCrazy](https://techcommunity.softwareag.com/u/PepsiCrazy)\
**Post date:** [May 19, 2008, 6:25pm UTC](https://techcommunity.softwareag.com/t/natural-ispf-editor-macros-to-collapse-expand-subroutines/60627/4 "2008-05-19T18:25:51Z")

</div>

Hi there,

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:40pm UTC](https://techcommunity.softwareag.com/t/natural-ispf-editor-macros-to-collapse-expand-subroutines/60627/5 "2021-04-02T14:40:29Z")

</div>


