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