home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv7.zip / vac22os2 / ibmcobol / macros / subzoom.lx < prev    next >
Text File  |  1998-02-24  |  3KB  |  88 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. parse upper var DOCTYPE DOCTYPE
  17. 'extract INCLUDE'     /* We'll use this at the end */
  18. identifier = "FUNCTION"         /* default - for C and CPP and CXX */
  19. if (DOCTYPE = 'RPG' | DOCTYPE = 'IRP' | DOCTYPE = 'VPG') then
  20.    identifier = "SUBROUTINE"
  21. if (DOCTYPE = 'CBL' | DOCTYPE = 'ICB') then
  22.    identifier = "DIVISION"
  23.  
  24. /* extrac the CLASS of the current line to see if we are on a subroutine */
  25. 'extract CLASS'
  26. if ((pos(identifier, CLASS) > 0) | (pos("ACTSUBS",CLASS) > 0) | (pos("SECTION",CLASS) > 0)) then do
  27.    if ((pos("DIVISION",CLASS) > 0)) then
  28.      identifier = "DIVISION"
  29.    else if ((pos("SECTION",CLASS) > 0)) then
  30.      identifier = "SECTION"
  31.    /* get classes and add SUBZOOM if its not already a CLASS  */
  32.    /* also get number of lines in the file. Used below        */
  33.    'extract CLASSES ELEMENTS'
  34.    if (pos("SUBZOOM", CLASSES) = 0) then do
  35.       'set CLASSES 'CLASSES' SUBZOOM'
  36.    end
  37.  
  38.    /* show/hide the subroutine statement line */
  39.    if (mode = "SHOW") then
  40.       'SET CLASS 'CLASS' SUBZOOM'
  41.    else do
  42.        /* delete SUBZOOM class */
  43.        parse var CLASS pre 'SUBZOOM' post
  44.        'SET CLASS 'pre' 'post
  45.    end
  46.  
  47.    /* get current line number and save it to restore position when done */
  48.    'extract ELEMENT INTO CURLINE'
  49.  
  50.    /* loop until the next subroutine, or end of file, showing or */
  51.    /* hiding each line.                                          */
  52.    done = 0
  53.    do until ((ELEMENT >= ELEMENTS) | (done = 1))
  54.       'NEXT'         /* go to next line */
  55.  
  56.       /* get current line number and contents */
  57.       'extract ELEMENT CONTENT CLASS'
  58.  
  59.       /* if class=subroutine, then we are on the last line of the routine */
  60.       if ((pos(identifier, CLASS) > 0) | (pos("ACTSUBS", CLASS) > 0)) then
  61.          done = 1
  62.  
  63.       /* if we get here then its a line within the current routine */
  64.       /* show/hide the subroutine statement line */
  65.       if (mode = "SHOW") then
  66.          'SET CLASS 'CLASS' SUBZOOM'
  67.       else do
  68.           /* delete SUBZOOM class */
  69.           parse var CLASS pre 'SUBZOOM' post
  70.           'SET CLASS 'pre' 'post
  71.       end
  72.    end  /* end of do while loop */
  73.  
  74.    /* show only the SUBZOOM class (ie. expanded routines and subroutines */
  75.      'set INCLUDE 'INCLUDE' SUBZOOM'
  76.  
  77.  
  78.    /* reset row to the row we were originally on */
  79.    'FIND ELEMENT 'CURLINE
  80. end
  81. else
  82.    if (DOCTYPE = 'CBL' | DOCTYPE = 'ICB') then
  83.      msg "Cursor is not on the beginning of a division or section"
  84.    else if (DOCTYPE = 'VPG') then
  85.      msg "Cursor is not on the beginning of a subroutine or action subroutine"
  86.    else
  87.      msg "Cursor is not on the beginning of a subroutine"
  88.