RNUM - REXX Renum utility


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /* Rexx - Renumber component/add fixtags */
  2. /**********************************************************************/
  3. /* Renumbers line numbers in a component (Source/Copybook) */
  4. /* NOTE - Switches on NUM & replaces blindly. Use with C A U T I O N */
  5. /**********************************************************************/
  6. /* ______ ______ _ _ _ _ ______ ______ _ _ | ______ */
  7. /* |____/ |_____ \__/ \__/ |_____ | | | --+-- |_____ */
  8. /* | \_ |_____ _/ \_ _/ \_ |_____ |_____ |____| | |_____ */
  9. /* */
  10. /**********************************************************************/
  11. /* Author - thecodeisclear */
  12. /* Version - 1.10 Language - REXX */
  13. /* Purpose - Renum set of lines as per given input */
  14. /* Input - strt - starting number/fix tag (Compulsory) */
  15. /* <strt-lbl> - starting label. Default first line (Optional) */
  16. /* <end-lbl> - ending label. Default last line (Optional) */
  17. /* <incr> - increment. Default 100 (Optional) */
  18. /* Output - Code is modified in the same dataset */
  19. /**********************************************************************/
  20. /* - - > M O D L O G < - - */
  21. /* 04/17/07 : Fixed bug when field 'strt' has leading zeros FX041707 */
  22. /* 10/15/10 : Provided an option to add fix tags instead of EH101510 */
  23. /* doing the renumber. incr will become optional */
  24. /* */
  25. /* */
  26. /* */
  27. /* */
  28. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  29. /* Turn on Signal to trap all errors/failures/syntax errors */
  30. signal on error
  31. signal on syntax
  32. signal on failure
  33. "ISREDIT MACRO (strt l1 l2 incr) NOPROCESS"
  34. If rc /= 0 then
  35. do
  36. say 'Edit environment not set'
  37. exit
  38. end
  39. "ispexec control errors return"
  40.  
  41. If strip(strt) = '' then
  42. do
  43. say 'Usage : rnum strt <strt-lbl> <end-lbl> <incr>'
  44. say ' '
  45. say ' strt - starting value/fix tag to add'
  46. say ' <strt-lbl> - starting label. Default first line.'
  47. say ' <end-lbl> - ending label. Default last line.'
  48. say ' <incr> - increment. Default 100'
  49. exit
  50. end
  51.  
  52. If strip(incr) = '' Then incr = 100
  53.  
  54. If strip(l1) = '' Then l1 = .zf
  55.  
  56. If strip(l2) = '' Then l2 = .zl
  57.  
  58. If datatype(strt) /= 'NUM'
  59. then do
  60. "ISREDIT C ALL P'========' 73" strt l1 l2 /*EH101510*/
  61. End
  62. Else Do
  63. If datatype(incr) /= 'NUM'
  64. then do
  65. say 'The increment counter must be numeric'
  66. exit
  67. end
  68.  
  69. /* To remove leading zeros in the strt variable */
  70. strt = strip(strt,'L',0) /*FX041707*/
  71.  
  72. width = length(strip(strt,b,''''))
  73.  
  74. If width > 6 Then
  75. Do
  76. Say 'Length of counter cannot be longer than 6 characters'
  77. exit
  78. End
  79. nChg = 0
  80. crc = 0
  81.  
  82. Do while crc = 0
  83.  
  84. strtx = strt
  85. if strt < 100000 then
  86. strtx = "0" || strt
  87. if strt < 10000 then
  88. strtx = "00" || strt
  89. if strt < 1000 then
  90. strtx = "000" || strt
  91. if strt < 100 then
  92. strtx = "0000" || strt
  93.  
  94. strtx = "'" || strtx || "'"
  95. "ISREDIT C 1 P'======' NEXT " strtx l1 l2
  96. crc = rc
  97. nChg = nChg + 1
  98. strt = strt + incr
  99. /* --- If after inc > 999999 exit --- */
  100. If strt > 999999 Then
  101. Do
  102. say ' '
  103. say ' - - - E R R O R - - - - - - - - - -'
  104. say ' Line number exceeds 999999. Completed ' || nChg || ' updates.'
  105. say ' Exiting now. Press Cancel to avoid saving the code.'
  106. say ' '
  107. say ' - - - S U G G E S T I O N S - - - -'
  108. say ' 1. Provide start and end labels. (or)'
  109. say ' 2. Give a smaller start/increment number.'
  110. Exit 8
  111. End
  112. End
  113. End /* End for strt check numeric */
  114. /* --- Go back to first location after Change --- */
  115. Address ISREDIT
  116. "locate " l1
  117.  
  118. Exit
  119. /* - - - - S U B R O U T I N E S - - - - - */
  120. /* */
  121. error: syntax: failure:
  122. Address TSO "clear"
  123. Say "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- E R R O R -=-=-=-=-=-=-"
  124. Say "An error occured during the execution of this utility. An error"
  125. Say "log has been created and stored. To track the status of this"
  126. Say "error, please contact the author with the reference"
  127. Say "ERR==>" sourceline(SIGL)
  128. Say "Con==>" condition('D')
  129. Say "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
  130. ht_exit:
  131. /* Turn on Signal Processing to prevent infinite loops */
  132. signal off error
  133. signal off syntax
  134. signal off failure
  135. /* Generic Exit Paragraph. */
  136. If datatype(ex_rc) ¬= 'NUM' Then
  137. Do
  138. ex_rc = 0
  139. End
  140. lgRC = ex_rc
  141. Exit ex_rc

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.