home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv7.zip / vac22os2 / ibmcobol / macros / iwzmssq.lx < prev    next >
Text File  |  1997-12-17  |  8KB  |  173 lines

  1. /* REXX */
  2. /*********************************************************************/
  3. /*                                                                   */
  4. /* Name: iwzmSSQ.LX                                                   */
  5. /*                                                                   */
  6. /* Function: Allows setting of columns 73-80 to a given value.       */
  7. /*           LPEX SHOW lines, such as language parser messages       */
  8. /*           or compilation error messages, are not affected.        */
  9. /*           This macro is intended fpr processing files that        */
  10. /*           are logically fixed 80 byte records (even though        */
  11. /*           on the workstation the records are physically           */
  12. /*           stored as variable length).                             */
  13. /*                                                                   */
  14. /* Note: this macro must be placed in the same directory as other    */
  15. /* LPEX macros before it can be invoked.                             */
  16. /*                                                                   */
  17. /* Invocation:                                                       */
  18. /*                                                                   */
  19. /* From the LPEX command line enter the following:                   */
  20. /*                                                                   */
  21. /* iwzmSSQ seqval <numrow> <REP>                                      */
  22. /*                                                                   */
  23. /* where:                                                            */
  24. /*                                                                   */
  25. /*   The < and > above indicate optional parameters.  The            */
  26. /*   parameters are blank delimited, so extra blanks before or       */
  27. /*   after a parameter are ignored.                                  */
  28. /*                                                                   */
  29. /*   seqval - the 1 to 8 character value to be placed in columns     */
  30. /*            73-80 starting in column 73.  The underscore (_)       */
  31. /*            characters indicates a blank in the value.  This       */
  32. /*            value is case sensitive.                               */
  33. /*                                                                   */
  34. /*   numrow - the number of rows, starting with the current row,     */
  35. /*            to be changed.  LPEX SHOW lines do not participate     */
  36. /*            in determining the number of lines to change, i.e.     */
  37. /*            they are ignored as if they did not exist.  If numrow  */
  38. /*            is not specified then only the current row is          */
  39. /*            changed.  A numrow specification of * indicates        */
  40. /*            that the change is to be made to all the lines to the  */
  41. /*            bottom of the file (still starting with the current    */
  42. /*            line).                                                 */
  43. /*                                                                   */
  44. /*   REP - indicates that existing data in columns 73-80 is          */
  45. /*         to be replaced.  The entire data is replaced.  If         */
  46. /*         REP is not specified then lines that already have         */
  47. /*         non-blank data in columns 73-80 are not changed.          */
  48. /*         Such rows that are not changed are however counted        */
  49. /*         as part of the number of rows to be changed.  This        */
  50. /*         parameter is not case sensitive and may be entered        */
  51. /*         in any case.                                              */
  52. /*                                                                   */
  53. /* The LPEX position in the file is preserved after invocation,      */
  54. /* i.e. after this macro finishes executing you remain in the        */
  55. /* same position in the file.                                        */
  56. /*                                                                   */
  57. /* Examples:                                                         */
  58. /*                                                                   */
  59. /* iwzmSSQ Jan_1997 10 rep                                            */
  60. /*                                                                   */
  61. /* this causes columns 73-80 of the next 10 lines, starting          */
  62. /* with the current line, to be set to the values "Jan 1997"         */
  63. /* (not included the quotes).                                        */
  64. /*                                                                   */
  65. /* iwzmSSQ FIX00357 1000                                              */
  66. /*                                                                   */
  67. /* this causes columns 73-80 of the next 1000 lines, starting        */
  68. /* with the current line, to be set to FIX00357.  Lines that         */
  69. /* already had a non-blank value in columns 73-80 are not            */
  70. /* changed.                                                          */
  71. /*                                                                   */
  72. /* Restrictions:                                                     */
  73. /*                                                                   */
  74. /* - the file must not be accessed as readonly.                      */
  75. /*                                                                   */
  76. /* - the LPEX textlimit for the file must be at least 80.            */
  77. /*   The normal LPEX default for textlimit is 2499 (even though      */
  78. /*   you only intend to edit up to 80 bytes per record).             */
  79. /*                                                                   */
  80. /* - if when processing the lines to be changed, a line is           */
  81. /*   encountered (other than an LPEX SHOW line) that is longer       */
  82. /*   than 80 characters the processing is terminated.  Such a        */
  83. /*   line implies that the data was not logically fixed 80 byte      */
  84. /*   records.                                                        */
  85. /*                                                                   */
  86. /*********************************************************************/
  87. trace off;
  88. signal on novalue;
  89. 'extract cursorrow into cursorrow';
  90. 'mark set @@iwzmssq@@';
  91. numchg = 0;
  92. parse arg seqval numrow replace rest;
  93. if seqval = '' then
  94.   call error 'Format is: iwzmssq seqval <numrows <rep>>>';
  95. if length(seqval) > 8 then
  96.   call error 'Value for columns 73-80 longer than 8';
  97. seqval = translate(seqval,' ','_');
  98. if translate(numrow) = 'REP' then
  99.   do;
  100.   replace = 'REP';
  101.   numrow = '';
  102.   end;
  103. if numrow = '' then
  104.   numrow = 1;
  105. if numrow = '*' then
  106.   numrow = 999999999;
  107. if datatype(numrow,'W') <> 1 then
  108.   call error 'Invalid number of rows';
  109. if numrow < 1 then
  110.   call error 'Invalid number of rows';
  111. if replace = '' then
  112. replace = 'NOREPLACE';
  113. replace = translate(replace);
  114. 'extract readonly into readonly';
  115. if readonly = 'ON' then
  116.   call error 'File is read only';
  117. 'extract textlimit into textlimit';
  118. if textlimit < 80 then
  119.   call error 'Textlimit set to less that 80';
  120. prevrow = 0;
  121. blanks = '                    ';
  122. blanks = blanks||blanks||blanks||blanks||blanks;
  123. 'check';
  124. numreal = 0;
  125. do forever;
  126.   'extract show into show';
  127.   if show = 'OFF' then
  128.     do;
  129.     numreal = numreal + 1
  130.     if numreal > numrow then
  131.       leave;
  132.     'extract content into line';
  133.     if length(line) > 80 then
  134.       call error 'Line longer than 80, processing stopped';
  135.     dochg = 'yes';
  136.     line = line||blanks;
  137.     curseq = substr(line,73,8);
  138.     if curseq <> '' & substr(replace,1,3) <> 'REP' then
  139.       dochg = 'no';
  140.     if dochg = 'yes' then
  141.       do;
  142.       line = substr(line,1,72)||seqval;
  143.       line = strip(line,'T');
  144.       'set content' line;
  145.       set_rc = rc;
  146.       if set_rc <> 0 then
  147.         call error 'Cannot change line, see macro log for details';
  148.       numchg = numchg + 1;
  149.       end;
  150.     end;
  151.   'next';
  152.   'extract element into numline';
  153.   if numline = prevrow then
  154.     leave;
  155.   prevrow = numline;
  156.   end;
  157. 'check';
  158. 'msg Lines changed =' numchg;
  159. 'mark find @@iwzmssq@@';
  160. 'mark clear @@iwzmssq@@';
  161. 'set focus.next' cursorrow;
  162. exit 0;
  163. /* */
  164. error:
  165. parse arg errmsg;
  166. 'check';
  167. 'mark find @@iwzmssq@@';
  168. 'mark clear @@iwzmssq@@';
  169. 'set focus.next' cursorrow;
  170. 'msg' errmsg ', lines changed =' numchg;
  171. 'alarm';
  172. exit 4;
  173.