home *** CD-ROM | disk | FTP | other *** search
/ Dream 53 / Amiga_Dream_53.iso / Amiga / Applications / PAO / ExtensionsPageStream / DuplicateToPag.lha / DuplicateToPage.rexx < prev   
OS/2 REXX Batch file  |  1998-03-29  |  4KB  |  173 lines

  1. /*
  2. ** -------------------------------------------
  3. **  $VER: DuplicateToPage V1.02 (29 Mar 1998)
  4. **  ⌐1997/98 Michael Merkel
  5. ** -------------------------------------------
  6. **
  7. ** Usage:
  8. **
  9. ** Just select the object(s) to duplicate.
  10. ** Than start ths script. Enter the page you want
  11. ** the object(s) to be copied and voila.
  12. **
  13. **
  14. ** Latest changes:
  15. **
  16. ** - added comments and cleaned up code
  17. **   1. READ THE CODE AND UNDERSTAND IT!
  18. **   2. SIT DOWN AND DO SCRIPTS BY YOURSELF! IT IS EASY!
  19. **
  20. ** - added a busy requester.
  21. **   operation can also be stoped now.
  22. **
  23. ** - removed stupid screen refresh command at end.
  24. **   (so it's faster now)
  25. **
  26. ** - Now works with more than one object!
  27. **   (thanks to Randall Blank for the report)
  28. */
  29.  
  30. pgsName    = 'DuplicateToPage'
  31. pgsVersion = 'V1.02'
  32. pgsDate    = '03/29/1998'
  33. pgsCopy    = '⌐1997/98 Michael Merkel'
  34.  
  35. OPTIONS RESULTS
  36.  
  37. /* Make sure rexx support is opened */
  38. IF ~SHOW('L','rexxsupport.library') THEN
  39.    CALL ADDLIB('rexxsupport.library',0,-30)
  40. IF ~SHOW('L','softlogik:libs/slarexxsupport.library') THEN
  41.    CALL ADDLIB('softlogik:libs/slarexxsupport.library',0,-30)
  42.  
  43. ADDRESS 'PAGESTREAM'
  44.  
  45. /*
  46. ** Get the number and IDs of all selected objects
  47. */
  48.  
  49. 'GETSELECTEDOBJECTS IDLIST objNum'
  50.  idCount = RESULT
  51.  
  52. /*
  53. ** No object selected? -> error message and quit
  54. */
  55.  
  56. IF (RC > 0)
  57. THEN DO
  58.     Call DoErrorRequester('No object(s) selected!')
  59.     Exit
  60. END
  61.  
  62. /*
  63. ** remember the current page number
  64. */
  65.  
  66. 'CURRENTPAGE'
  67.  page = RESULT
  68.  
  69. /*
  70. ** Ask user on which page the copies will go
  71. */
  72.  
  73. Call DoRequester
  74.  
  75. IF (ergebnis = cancelhandler)
  76. THEN Exit
  77.  
  78. /*
  79. ** Open a busy requester and disable refreshing
  80. */
  81.  
  82. busyHandle = OpenBusy( 'Duplicating objects...', (idCount-1) )
  83.  
  84. 'REFRESH OFF'
  85.  
  86. /*
  87. ** Run over all selected objects and duplicate them.
  88. ** Move the duplicates to the desired page.
  89. ** (Always update the busy requester)
  90. */
  91.  
  92. DO k=0 TO (idCount-1)
  93.     IF ( SetBusy(busyHandle, k) = 1 )
  94.     THEN Call CleanUp(busyHandle)
  95.  
  96.     'DUPLICATE OFFSET "0" "0" OBJECTID "'objNum.k'"'
  97.     'MOVETOPAGE PAGE "'page'" OBJECTID "'objNum.k'"'
  98. END
  99.  
  100. /*
  101. ** Close the busy requester and enable refresh.
  102. */
  103.  
  104. Call CleanUp(busyHandle)
  105.  
  106. DoRequester:
  107.     xWin = 400
  108.     yWin = 60
  109.  
  110.     'ALLOCAREXXREQUESTER "'|| pgsName pgsVersion ||' ('|| pgsDate ||') - '|| pgsCopy ||'" '|| xWin yWin
  111.      reqHandle = RESULT
  112.     'ADDAREXXGADGET 'reqHandle' EXIT 10 '|| (yWin - 20) ||' 70 LABEL "_Ok"'
  113.      okHandler = RESULT
  114.     'ADDAREXXGADGET 'reqHandle' EXIT '|| (xWin - 80) (yWin - 20) ||' 70 LABEL "_Cancel"'
  115.      cancelHandler = RESULT
  116.  
  117.     'ADDAREXXGADGET 'reqhandle' STRING 200 10 80 STRING "'page'" LABEL "Duplicate to which page:"'
  118.      page_gadget = RESULT
  119.  
  120.     'DOAREXXREQUESTER 'reqhandle
  121.      ergebnis = RESULT
  122.  
  123.     'GETAREXXGADGET 'reqhandle' 'page_gadget' STRING'
  124.      page = RESULT
  125.  
  126.     'FREEAREXXREQUESTER 'reqhandle
  127. Return
  128.  
  129. DoErrorRequester:
  130.     PARSE ARG text
  131.     xSize = Length(text) * 8
  132.  
  133.     'ALLOCAREXXREQUESTER "'pgsName pgsVersion'" '|| (xSize+20) ||' 50'
  134.      reqHandle = RESULT
  135.     'ADDAREXXGADGET 'reqHandle' EXIT '|| (xSize/2+10-35) ||' 30 70 LABEL "_Ok"'
  136.      dummy = RESULT
  137.  
  138.     'ADDAREXXGADGET 'reqHandle' TEXT 10 10 '|| xSize ||' STRING "'|| text ||'"'
  139.  
  140.     'DOAREXXREQUESTER 'reqHandle
  141.      dummy = RESULT
  142.  
  143.     'FREEAREXXREQUESTER 'reqHandle
  144. Return
  145.  
  146. OpenBusy:
  147.     PARSE ARG title,total
  148.  
  149.     'OPENBUSYREQUESTER MESSAGE "'title'" THERMOMETER ENABLED ABORT ENABLED TOTAL 'total' CURRENT 0'
  150.     ret = RESULT
  151. Return ret
  152.  
  153. SetBusy:
  154.     PARSE ARG reqNum,value
  155.  
  156.     IF (reqNum > 0)
  157.     THEN DO
  158.         'SETBUSYREQUESTER '|| reqNum ||' CURRENT '|| value ||''
  159.         'GETBUSYREQUESTER '|| reqNum
  160.         ret = RESULT
  161.     END
  162.     ELSE ret = 0
  163. Return ret
  164.  
  165. CleanUp:
  166.     PARSE ARG reqNum
  167.  
  168.     IF (reqNum > 0)
  169.     THEN 'CLOSEBUSYREQUESTER '|| reqNum ||''
  170.  
  171.     'REFRESH ON'
  172. Exit
  173.