home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv7.zip / vac22os2 / ibmcobol / macros / repeats.lx < prev    next >
Text File  |  1998-02-24  |  1KB  |  38 lines

  1. /* This macro repeats a command a given number of times */
  2. /* Two dialogs are issued - the first collects the number */
  3. /* the second the command to repeat  */
  4. /* Note: if a number is not entered the macro ends and a message is issued */
  5. /* Note: only valid editor commands are accepted on the second dialog   */
  6.  
  7. 'set lineread.title Repeat a Command'
  8. 'set lineread.prompt Enter the number of time to repeat:'
  9. 'lineread 255'
  10. 'extract lastkey'
  11. if lastkey = 'ENTER' then do
  12. 'extract lastline'
  13. end
  14.  
  15.   if datatype(lastline) = NUM        /* check that a number was entered */
  16.               then do
  17.                         numrep = lastline
  18.               end
  19.  
  20.               else do
  21.               MSG 'You must enter a valid number'
  22.               return
  23.               end
  24.  
  25. /* get the second piece of information   */
  26.  
  27. 'set lineread.title Repeat a Command'
  28. 'set lineread.prompt Enter the command to repeat:'
  29. 'lineread 255'
  30. 'extract lastkey'
  31. if lastkey = 'ENTER' then do
  32. 'extract lastline'
  33. end
  34. cmd_rep = lastline
  35.  
  36.               /* substitute the values entered and run repeat command */
  37. 'repeat' numrep cmd_rep
  38.