home *** CD-ROM | disk | FTP | other *** search
/ Merciful 3 / Merciful_Release_3.bin / software / d / draw_studio / drawstudiov1.0.2a.dms / drawstudiov1.0.2a.adf / DSdir1.lha / Rexx / Tile.dsrx < prev    next >
Text File  |  1996-11-03  |  4KB  |  175 lines

  1. /* Allow commands to return results */
  2.  
  3. options results
  4.  
  5. /* On error, goto ERROR:. Comment out this line if you wish to */
  6. /* perform your own error checking. */
  7.  
  8. signal on error
  9.  
  10. 'PROJECT_LOCK'
  11.  
  12. /* BEGIN PROGRAM *************************************************/
  13.  
  14. /*
  15. PROGRAM:        Tile.dsdr
  16. DESCRIPTION:    General purpose script for tiling objects on a
  17.         page. Place an object on the page, leaving a
  18.         top and left margin and the object will be
  19.         tiled to fill the page, leaving the same margin
  20.         for the bottom and right of the page. A gutter
  21.         value may be given to leave space between the
  22.         tiled objects.
  23. DATE:           03/11/96
  24. AUTHOR:         Andy Dean
  25. */
  26.  
  27. /* Gutter values, in points */
  28.  
  29. GutterX = 0
  30. GutterY = 0
  31.  
  32. REDRAW_OFF
  33.  
  34. /* Get info on the selected object(s) */
  35.  
  36. OBJECT_SPECS_GET stem 'srcobj.'
  37.  
  38. /* If there's more than 1 object, group them */
  39. /* and store their name */
  40.  
  41. if srcobj.numselected > 1 then do
  42.     OBJECT_GROUP stem 'srcgrp.'
  43.     
  44.     srcname = srcgrp.name
  45.     end
  46. else do
  47.     srcname = srcobj.name
  48.     end
  49.                     
  50. /* Get the object specs */
  51.  
  52. OBJECT_SPECS_GET stem 'objspec.'
  53.  
  54. marginx = objspec.left
  55. marginy = objspec.top
  56.  
  57. objw = objspec.width
  58. objh = objspec.height
  59.  
  60. /* Get the page specs */
  61.  
  62. PAGE_SPECS_GET stem 'pagespec.'
  63.  
  64. /* How many times can we tile horizontally ? */
  65.  
  66. numx = pagespec.width - (2 * marginx)
  67. numx = numx / (objw + GutterX)
  68.  
  69. /* How many times can we tile vertically ? */
  70.  
  71. numy = pagespec.height - (2 * marginy)
  72. numy = numy / (objh + GutterY)
  73.  
  74. /* Tile the objects */
  75.  
  76. do ly = 0 to (numy - 1)
  77.     do lx = 0 to (numx - 1)
  78.         /* Don't clone onto original */
  79.  
  80.         if lx + ly = 0 then do
  81.             nop
  82.  
  83.             end
  84.         else do
  85.             /* Clone object */
  86.     
  87.             OBJECT_CLONE '"'lx * (objw + GutterX)'"',
  88.                 '"'ly * (objh + GutterY)'"',
  89.             
  90.             /* Ungroup, if the src obj was ungrouped */
  91.  
  92.             if srcobj.numselected > 1 then
  93.                 OBJECT_UNGROUP
  94.  
  95.             /* Select the source object again */
  96.     
  97.             OBJECT_DESELECT
  98.             OBJECT_SELECT '"'srcname'"'
  99.  
  100.             end
  101.         end
  102.     end
  103.  
  104. /* If it was grouped, ungroup */
  105.  
  106. if srcobj.numselected > 1 then
  107.     OBJECT_UNGROUP
  108.  
  109. REDRAW_ON
  110.  
  111. /* END PROGRAM ***************************************************/
  112.  
  113. 'PROJECT_UNLOCK'
  114.  
  115. exit
  116.  
  117. /* On ERROR */
  118.  
  119. ERROR:
  120.  
  121. 'PROJECT_UNLOCK'
  122.  
  123. /* If we get here, either an error occurred with the command's */
  124. /* execution or there was an error with the command itself. */
  125. /* In the former case, rc2 contains the error message and in */
  126. /* the latter, rc2 contains an error number. SIGL contains */
  127. /* the line number of the command which caused the jump */
  128. /* to ERROR: */
  129.  
  130. if datatype(rc2,'NUMERIC') == 1 then do
  131.     /* See if we can describe the error with a string */
  132.  
  133.     select
  134.         when rc2 == 103 then
  135.             err_string = "ERROR 103, "||,
  136.                 "out of memory at line "||SIGL
  137.         when rc2 == 114 then
  138.             err_string = "ERROR 114, "||,
  139.                 "bad command template at line "||SIGL
  140.         when rc2 == 115 then
  141.             err_string = "ERROR 115, "||,
  142.                 "bad number for /N argument at line "||SIGL
  143.         when rc2 == 116 then
  144.             err_string = "ERROR 116, "||,
  145.                 "required argument missing at line "||SIGL
  146.         when rc2 == 117 then
  147.             err_string = "ERROR 117, "||,
  148.                 "value after keywork missing at line "||SIGL
  149.         when rc2 == 118 then
  150.             err_string = "ERROR 118, "||,
  151.                 "wrong number of arguments at line "||SIGL
  152.         when rc2 == 119 then
  153.             err_string = "ERROR 119, "||,
  154.                 "unmatched quotes at line "||SIGL
  155.         when rc2 == 120 then
  156.             err_string = "ERROR 120, "||,
  157.                 "line too long at line "||SIGL
  158.         when rc2 == 236 then
  159.             err_string = "ERROR 236, "||,
  160.                 "unknown command at line "||SIGL
  161.         otherwise
  162.             err_string = "ERROR "||rc2||", at line "||SIGL
  163.         end
  164.     end
  165. else if rc2 == 'RC2' then do
  166.     err_string = "ERROR in command at line "||SIGL
  167.     end
  168. else do
  169.     err_string = rc2||", line "||SIGL
  170.     end
  171.  
  172. req_message TEXT '"'err_string'"'
  173.  
  174. exit
  175.