home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv7.zip / VACPP / IBMCPP / macros / SUBZOOM.LX < prev    next >
Text File  |  1995-05-11  |  2KB  |  74 lines

  1. /* zoom in or out on a subroutine                       */
  2. /* format : SUBZOOM HIDE | SHOW. If no parms, then SHOW */
  3.  
  4. /* get parameters */
  5. arg mode
  6.                
  7. /* reset prefix command, if there was one */
  8. 'set prefixentry'
  9.  
  10. /* if not parm, then set to default */
  11. if (mode = "") then
  12.    mode = 'SHOW'
  13.  
  14. /* determine if this is an RPG document, as its the only type we support */
  15. 'extract DOCTYPE'
  16. identifier = "FUNCTION"         /* default - for C and CPP and CXX */
  17. if (DOCTYPE = 'RPG') then
  18.    identifier = "SUBROUTINE"
  19.  
  20. /* extrac the CLASS of the current line to see if we are on a subroutine */
  21. 'extract CLASS'
  22. if (pos(identifier, CLASS) > 0) then do
  23.    /* get classes and add SUBZOOM if its not already a CLASS  */
  24.    /* also get number of lines in the file. Used below        */
  25.    'extract CLASSES ELEMENTS'
  26.    if (pos("SUBZOOM", CLASSES) = 0) then do
  27.       'set CLASSES 'CLASSES' SUBZOOM'
  28.    end
  29.  
  30.    /* show/hide the subroutine statement line */
  31.    if (mode = "SHOW") then
  32.       'SET CLASS 'CLASS' SUBZOOM'
  33.    else do
  34.        /* delete SUBZOOM class */
  35.        parse var CLASS pre 'SUBZOOM' post
  36.        'SET CLASS 'pre' 'post
  37.    end
  38.  
  39.    /* get current line number and save it to restore position when done */
  40.    'extract ELEMENT INTO CURLINE'
  41.  
  42.    /* loop until the next subroutine, or end of file, showing or */
  43.    /* hiding each line.                                          */
  44.    done = 0
  45.    do until ((ELEMENT >= ELEMENTS) | (done = 1))
  46.       'NEXT'         /* go to next line */
  47.  
  48.       /* get current line number and contents */
  49.       'extract ELEMENT CONTENT CLASS'
  50.  
  51.       /* if class=subroutine, then we are on the last line of the routine */
  52.       if (pos(identifier, CLASS) > 0) then
  53.          done = 1
  54.  
  55.       /* if we get here then its a line within the current routine */
  56.       /* show/hide the subroutine statement line */
  57.       if (mode = "SHOW") then
  58.          'SET CLASS 'CLASS' SUBZOOM'
  59.       else do
  60.           /* delete SUBZOOM class */
  61.           parse var CLASS pre 'SUBZOOM' post
  62.           'SET CLASS 'pre' 'post
  63.       end
  64.    end  /* end of do while loop */
  65.  
  66.    /* show only the SUBZOOM class (ie. expanded routines and subroutines */
  67.    'set INCLUDE 'identifier' SUBZOOM'
  68.  
  69.    /* reset row to the row we were originally on */
  70.    'FIND ELEMENT 'CURLINE
  71. end
  72. else
  73.    msg "Cursor is not on the beginning of a subroutine"
  74.