home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / the25.zip / the25O_os2.zip / comm.the < prev    next >
Text File  |  1997-09-10  |  4KB  |  81 lines

  1. /*
  2. $Id: comm.the 2.1 1995/06/24 16:28:42 MH Rel MH $
  3. */
  4. /***********************************************************************/
  5. /* Description: REXX macro to comment lines.                           */
  6. /* Syntax:      comm [target]                                          */
  7. /* Notes:       This macro will comment lines based on the file        */
  8. /*              type or file name as per below:                        */
  9. /*               .c       - /* */                                      */
  10. /*               .h       - /* */                                      */
  11. /*               .rex     - /* */                                      */
  12. /*               .rexx    - /* */                                      */
  13. /*               .pas     - (* *)                                      */
  14. /*               .asm     - ;                                          */
  15. /*               .htm     - <!-- -->                                   */
  16. /*               .html    - <!-- -->                                   */
  17. /*               makefile - #                                          */
  18. /*               Makefile - #                                          */
  19. /*              Full XEDIT/KEDIT/THE targets are supported.            */
  20. /***********************************************************************/
  21. Trace o
  22. arg1 = Arg(1)
  23. noargs = Arg()
  24. If noargs = 0 Then arg1 = '1'               /* no args - assume 1 line */
  25. forward = 1                  /* assume direction is forward by default */
  26. 'EXTRACT /LINE/SIZE/STAY/FTYPE/FNAME/LINEND'      /* get various stuff */
  27. current_line = line.1                   /* save current line for later */
  28. reply = valid_target(arg1)                 /* validate supplied target */
  29. If reply = 'ERROR' Then
  30.    Do
  31.      'EMSG Error 0017: Invalid target' arg1
  32.      Exit
  33.    End
  34. If reply = 'NOTFOUND' Then
  35.    Do
  36.      'EMSG Error 0017: Target not found' arg1
  37.      Exit
  38.    End
  39. 'preserve'
  40. start_line = Word(reply,1)                        /* get starting line */
  41. nolines = Word(reply,2)                         /* get number of lines */
  42. If nolines < 0 Then Do                /* if target before current line */
  43.    forward = 0                    /* indicate direction to be backward */
  44.    nolines = nolines * -1                     /* make nolines positive */
  45. End
  46. If fname.1 = 'makefile' |  fname.1 = 'Makefile' Then 'SET LINEND OFF'
  47. ':'||start_line                                    /* go to first line */
  48. totlines = 0                             /* reset changed line counter */
  49. Do nolines                              /* for each line to target ... */
  50.    'EXTRACT /CURLINE/TOF/EOF/'       /* get current line contents, etc.*/
  51.    If tof.1 = 'ON',                    /* ignore line if on TOF or EOF */
  52.    |  eof.1 = 'ON' Then nop
  53.    Else
  54.       Do
  55.         Select               /* add comment characters to current line */
  56.           When ftype.1 = 'c' Then 'REPLACE' '/*'||curline.3||'*/'
  57.           When ftype.1 = 'h' Then 'REPLACE' '/*'||curline.3||'*/'
  58.           When ftype.1 = 'rex' Then 'REPLACE' '/*'||curline.3||'*/'
  59.           When ftype.1 = 'rexx' Then 'REPLACE' '/*'||curline.3||'*/'
  60.           When ftype.1 = 'pas' Then 'REPLACE' '(*'||curline.3||'*)'
  61.           When ftype.1 = 'asm' Then 'REPLACE' ';'||curline.3
  62.           When ftype.1 = 'sql' Then 'REPLACE' 'rem '||curline.3
  63.           When ftype.1 = 'for' Then 'REPLACE' 'C '||curline.3
  64.           When ftype.1 = 'htm' Then 'REPLACE' '<!--' curline.3  '-->'
  65.           When ftype.1 = 'html' Then 'REPLACE' '<!--' curline.3  '-->'
  66.           When fname.1 = 'makefile' Then 'REPLACE' '#'||curline.3
  67.           When fname.1 = 'Makefile' Then 'REPLACE' '#'||curline.3
  68.           Otherwise 'REPLACE' '/*'||curline.3||'*/'
  69.         End
  70.         totlines = totlines + 1
  71.       End
  72.    If forward = 1 Then 'N'          /* if going forward, get next line */
  73.    Else 'U'                   /* if going backwards, get previous line */
  74.    If rc \= 0 Then Leave                         /* shouldn't get here */
  75. End
  76. If fname.1 = 'makefile' |  fname.1 = 'Makefile' Then 'SET LINEND' linend.1 linend.2
  77. 'EMSG' totlines 'lines commented'        /* say how many lines changed */
  78. If stay.1 = 'ON' Then ':'||current_line 
  79. 'restore'
  80. Return                                               /* go back to THE */
  81.