home *** CD-ROM | disk | FTP | other *** search
/ CorelDRAW! 10 / cd10_pgrm.iso / Corel / Graphics10 / Draw / Scripts / Misc / replica.csc < prev    next >
Encoding:
Text File  |  1997-08-19  |  16.8 KB  |  534 lines

  1. REM Repeatedly duplicates or clones
  2. REM the currently selected object.
  3.  
  4. '********************************************************************
  5. '   Script:    Replica.csc
  6. '   Copyright 1996 Corel Corporation.  All rights reserved.
  7. '   Description: CorelDRAW script to repeatedly duplicate or
  8. '                clone the currently selected object.
  9. '********************************************************************
  10.  
  11. #addfol  "..\..\..\Scripts"
  12. #include "ScpConst.csi"
  13. #include "DrwConst.csi"
  14.  
  15. '/////FUNCTION & SUBROUTINE DECLARATIONS/////////////////////////////
  16. DECLARE FUNCTION CheckForSelection() AS BOOLEAN
  17. DECLARE FUNCTION ValidateInput(OperationType AS INTEGER,        \\
  18.                             BYREF Reps AS INTEGER,            \\
  19.                             BYREF Horiz AS INTEGER,            \\
  20.                             BYREF Vert AS INTEGER,            \\
  21.                             HorizUnit AS INTEGER,            \\
  22.                             VertUnit AS INTEGER) AS BOOLEAN
  23. DECLARE SUB DoOperation(OperationType AS INTEGER,                \\
  24.                       Reps AS INTEGER,                    \\
  25.                      Horiz AS INTEGER,                    \\
  26.                      Vert AS INTEGER,                    \\
  27.                      HorizUnit AS INTEGER,                 \\
  28.                      VertUnit AS INTEGER)
  29.  
  30. '/////GLOBAL VARIABLES & CONSTANTS///////////////////////////////////
  31. GLOBAL CONST OPERATION_DUPLICATE% = 0
  32. GLOBAL CONST OPERATION_CLONE%     = 1
  33. GLOBAL CONST TITLE_ERRORBOX$      = "Replicate Script Error"
  34. GLOBAL CONST TITLE_INFOBOX$       = "Replicate Script Information"
  35. GLOBAL NL AS STRING         ' These must be declared as 
  36. GLOBAL NL2 AS STRING     ' variables, not constants, because
  37. NL$ = CHR(10) + CHR(13)    ' we cannot assign expressions
  38. NL2$ = NL + NL             ' to constants.
  39.  
  40. ' Constants for dialog return values.
  41. GLOBAL CONST DIALOG_RETURN_OK%     = 1
  42. GLOBAL CONST DIALOG_RETURN_CANCEL% = 2
  43.  
  44. '/////OPTIONS DIALOG/////////////////////////////////////////////////
  45.  
  46. ' The array of possible units the user may select from.
  47. DIM UnitsArray(6) AS STRING
  48. UnitsArray(1) = "1 in."
  49. UnitsArray(2) = "1/36 in."
  50. UnitsArray(3) = "0.001 in."
  51. UnitsArray(4) = "1 cm."
  52. UnitsArray(5) = "0.001 cm."
  53. UnitsArray(6) = "1 pt."
  54.  
  55. ' Set defaults for the dialog.
  56. DIM OperationType AS INTEGER        ' Duplicate or clone?
  57. DIM Reps AS INTEGER                ' Repeat how many times?
  58. DIM Horiz AS INTEGER            ' Horizontal offset.
  59. DIM Vert AS INTEGER                ' Vertical offset.
  60. DIM HorizUnit AS INTEGER            ' Horizontal offset units.
  61. DIM VertUnit  AS INTEGER            ' Vertical offset units.
  62. OperationType% = OPERATION_DUPLICATE%
  63. Reps% = 3
  64. Horiz% = 2
  65. Vert% = 2
  66. HorizUnit% = 1
  67. VertUnit%  = 1
  68.  
  69. ' This is the main options dialog.
  70. BEGIN DIALOG OptionsDialog 207, 182, "Replication Options"
  71.     TEXT  10, 6, 175, 31, "This script repeatedly duplicates or clones the currently selected object."
  72.     OKBUTTON  47, 161, 50, 13
  73.     CANCELBUTTON  107, 161, 50, 13
  74.     OPTIONGROUP OperationType%
  75.         OPTIONBUTTON  24, 42, 50, 15, "Duplicate"
  76.         OPTIONBUTTON  24, 60, 40, 10, "Clone"
  77.     GROUPBOX  12, 90, 185, 60, "Place duplicates and clones"
  78.     SPINCONTROL  132, 52, 54, 12, Reps%
  79.     SPINCONTROL  66, 108, 54, 12, Horiz%
  80.     DDLISTBOX  132, 108, 54, 197, UnitsArray$, HorizUnit%
  81.     SPINCONTROL  66, 126, 54, 12, Vert%
  82.     DDLISTBOX  132, 126, 54, 178, UnitsArray$, VertUnit%
  83.     TEXT  24, 110, 35, 11, "Horizontal:"
  84.     TEXT  24, 127, 35, 10, "Vertical:"
  85.     GROUPBOX  12, 30, 186, 48, "Operation"
  86.     TEXT  84, 52, 42, 12, "How many"
  87.     TEXT  124, 109, 6, 11, "x"
  88.     TEXT  124, 127, 6, 11, "x"
  89. END DIALOG
  90.  
  91. '********************************************************************
  92. ' MAIN
  93. '
  94. '
  95. '********************************************************************
  96.  
  97. '/////LOCAL VARIABLES////////////////////////////////////////////////
  98. DIM MessageText AS STRING    ' Text to use in a MESSAGEBOX.
  99. DIM GenReturn AS INTEGER        ' The return value of various routines.
  100. DIM Selection AS BOOLEAN        ' Whether any object is selected in draw.
  101. DIM Valid AS BOOLEAN        ' Whether the user's options were valid.
  102.  
  103. ' Check to see if CorelDRAW's automation object is available.
  104. ON ERROR RESUME NEXT
  105. WITHOBJECT OBJECT_DRAW
  106.     IF (ERRNUM > 0) THEN
  107.         ' Failed to create the automation object.
  108.         ERRNUM = 0
  109.         GenReturn = MESSAGEBOX( "Could not find CorelDRAW."+NL2+\\
  110.                             "If this error persists, you "+ \\
  111.                             "may need to re-install "+      \\
  112.                             "CorelDRAW.",                 \\
  113.                                TITLE_ERRORBOX,                 \\
  114.                             MB_OK_ONLY )
  115.         STOP
  116.     ENDIF
  117.  
  118. ' Set up a general error handler.
  119. ON ERROR GOTO MainErrorHandler
  120.  
  121. ' Check whether anything is selected.
  122. Selection = CheckForSelection() 
  123.  
  124. IF NOT Selection THEN
  125.     MessageText$ = "Please select an object to replicate or "
  126.     MessageText$ = MessageText$ + "clone before running this script."
  127.     GenReturn% = MESSAGEBOX(MessageText$, TITLE_INFOBOX$, \\
  128.                             MB_OK_ONLY& OR MB_INFORMATION_ICON&)
  129.     STOP
  130. ENDIF
  131.  
  132. ' Display the user-interface dialog.
  133. DO
  134.  
  135.     GenReturn = DIALOG(OptionsDialog)
  136.     SELECT CASE GenReturn
  137.  
  138.         CASE DIALOG_RETURN_OK
  139.             Valid = ValidateInput(OperationType%,            \\
  140.                                Reps%,                     \\
  141.                               Horiz%,                    \\
  142.                               Vert%,                    \\
  143.                               HorizUnit%,                \\
  144.                               VertUnit%)
  145.             
  146.         CASE DIALOG_RETURN_CANCEL
  147.             STOP
  148.  
  149.         CASE ELSE
  150.             FAIL ERR_USER_FIRST
  151.  
  152.     END SELECT
  153.  
  154. LOOP UNTIL Valid
  155.  
  156. ' Perform the main processing.
  157. DoOperation OperationType, Reps, Horiz, Vert, HorizUnit, VertUnit
  158. STOP
  159.  
  160. MainErrorHandler:
  161.     ERRNUM = 0
  162.     MessageText$ = "A general error occurred during the "
  163.     MessageText$ = MessageText$ + "replication process." + NL2
  164.     MessageText$ = MessageText$ + "You may wish to try again."
  165.     GenReturn% = MESSAGEBOX(MessageText$, TITLE_ERRORBOX$, \\
  166.                             MB_OK_ONLY& OR MB_EXCLAMATION_ICON&)
  167.     STOP
  168.  
  169. '********************************************************************
  170. '
  171. '    Name:    CheckForSelection (function)
  172. '
  173. '    Action:    Checks whether an object is currently selected
  174. '            in CorelDRAW.
  175. '
  176. '    Params:    None
  177. '
  178. '    Returns:    TRUE if an object is currently selected;  FALSE
  179. '            otherwise.
  180. '
  181. '    Comments:    Never raises any errors. 
  182. '
  183. '********************************************************************
  184. FUNCTION CheckForSelection AS BOOLEAN
  185.  
  186.     DIM ObjType AS LONG     ' The currently selected object type.
  187.     
  188.     ON ERROR RESUME NEXT
  189.     ObjType& = .GetObjectType()
  190.     IF (ObjType& <= 0) OR (ERRNUM > 0) THEN
  191.         ERRNUM = 0
  192.         CheckForSelection = FALSE
  193.     ELSE
  194.         CheckForSelection = TRUE
  195.     ENDIF
  196.  
  197. END FUNCTION
  198.  
  199. '********************************************************************
  200. '
  201. '    Name:    ValidateInput (function)
  202. '
  203. '    Action:    Checks whether the options the user entered make 
  204. '              sense.
  205. '
  206. '    Params:    OperationType - Clone or duplicate?
  207. '            Reps          - The number of repetitions.
  208. '            Horiz         - The Horizontal offset distance.
  209. '            Vert          - The vertical offset distance.
  210. '            HorizUnit     - What unit is Horiz?
  211. '            VertUnit      - What unit is Vert? 
  212. '
  213. '    Returns:    TRUE if the input makes sense, FALSE otherwise.
  214. '
  215. '    Comments:    Never raises any errors.
  216. '              Does not ensure that all numbers are perfectly
  217. '              valid (ie. Horiz may take the object off the page),
  218. '              only that they are sane (ie. Reps is positive).
  219. '
  220. '********************************************************************
  221. FUNCTION ValidateInput(OperationType AS INTEGER,                \\
  222.                    BYREF Reps AS INTEGER,                \\
  223.                    BYREF Horiz AS INTEGER,                \\
  224.                    BYREF Vert AS INTEGER,                \\
  225.                    HorizUnit AS INTEGER,                    \\
  226.                    VertUnit AS INTEGER) AS BOOLEAN
  227.  
  228.     DIM ReturnVal% AS INTEGER    ' The return value of MESSAGEBOX.
  229.     DIM AvailableX AS LONG        ' The page width.
  230.     DIM AvailableY AS LONG        ' The page height.
  231.     DIM FinalX AS LONG            ' The final x position.
  232.     DIM FinalY AS LONG            ' The final y position.
  233.     
  234.     ' This error handler ensures no error will ever propagate
  235.     ' out of this function.
  236.     ON ERROR GOTO VIGeneralError
  237.     
  238.     ' Check if Reps is positive.
  239.     IF (Reps% < 1) THEN
  240.         ReturnVal% = MESSAGEBOX("You have requested "+CSTR(Reps) + \\
  241.                               " repetitions.  This is not a valid "+ \\
  242.                               "number."+NL2+"Please try again, "   + \\
  243.                               "remembering to choose a number "    + \\
  244.                               "greater than 0.", TITLE_ERRORBOX$,    \\
  245.                               MB_OK_ONLY)
  246.         Reps% = 1
  247.         ValidateInput = FALSE
  248.         EXIT FUNCTION
  249.     ELSEIF (Reps% >= 32767) THEN
  250.         ReturnVal% = MESSAGEBOX("You have requested a very large number of repetitions." + \\
  251.                                 NL + "This number is too high." + NL2 + \\
  252.                             "Please try again, remembering to choose " + \\
  253.                             "a number less than 100.", TITLE_ERRORBOX$, \\
  254.                             MB_OK_ONLY)
  255.         Reps% = 99
  256.         ValidateInput = FALSE
  257.         EXIT FUNCTION
  258.     ELSEIF (Reps% > 99) THEN
  259.         ReturnVal% = MESSAGEBOX("You have requested " + CSTR(Reps) + \\
  260.                             " repetitions.  This number is too high." + NL2 + \\
  261.                             "Please try again, remembering to choose " + \\
  262.                             "a number less than 100.", TITLE_ERRORBOX$, \\
  263.                             MB_OK_ONLY)
  264.         Reps% = 99
  265.         ValidateInput = FALSE
  266.         EXIT FUNCTION
  267.     ENDIF
  268.  
  269.     ' Check the range of Horiz.
  270.     IF (ABS(Horiz%) > 999) THEN
  271.         ReturnVal% = MESSAGEBOX("You have entered a very large or very small number" + NL + \\
  272.                                 "for the horizontal offset." + NL2 + \\
  273.                                 "Valid values are from -999 to 999." + NL + \\
  274.                             "Please try again, remembering to choose " + \\
  275.                             "a number in this range.", TITLE_ERRORBOX$, \\
  276.                             MB_OK_ONLY)
  277.         Horiz% = 0
  278.         IF (ABS(Vert%) > 999) THEN
  279.             Vert% = 0
  280.         ENDIF
  281.         ValidateInput = FALSE
  282.         EXIT FUNCTION
  283.     ENDIF
  284.  
  285.     ' Check the range of Vert.
  286.     IF (ABS(Vert%) > 999) THEN
  287.         ReturnVal% = MESSAGEBOX("You have entered a very large or very small number" + NL + \\
  288.                                 "for the vertical offset." + NL2 + \\
  289.                                 "Valid values are from -999 to 999." + NL + \\
  290.                             "Please try again, remembering to choose " + \\
  291.                             "a number" + NL + "in this range.", TITLE_ERRORBOX$, \\
  292.                             MB_OK_ONLY)
  293.         Vert% = 0
  294.         IF (ABS(Horiz%) > 999) THEN
  295.             Vert% = 0
  296.         ENDIF
  297.         ValidateInput = FALSE
  298.         EXIT FUNCTION
  299.     ENDIF
  300.  
  301.     ' Check the range.
  302.     .GetPageSize AvailableX&, AvailableY&
  303.     
  304.     ' Make sure we're never going off the page.
  305.     SELECT CASE HorizUnit%
  306.     
  307.         CASE 1 ' 1 in.
  308.             FinalX& = Horiz% * Reps% * 1 * \\
  309.                      LENGTHCONVERT(LC_INCHES, \\
  310.                                    LC_TENTHS_OFA_MICRON, \\
  311.                                 1)
  312.         CASE 2 ' 1/36 in.
  313.             FinalX& = Horiz% * Reps% * (1/36) *   \\
  314.                      LENGTHCONVERT(LC_INCHES,       \\
  315.                                    LC_TENTHS_OFA_MICRON, \\
  316.                                 1)
  317.         CASE 3 ' 0.001 in.
  318.             FinalX& = Horiz% * Reps% * 0.001 *    \\
  319.                      LENGTHCONVERT(LC_INCHES,       \\
  320.                                    LC_TENTHS_OFA_MICRON, \\
  321.                                 1)
  322.         CASE 4 ' 1 cm.
  323.             FinalX& = Horiz% * Reps% * 1 *        \\
  324.                      LENGTHCONVERT(LC_CENTIMETERS,  \\
  325.                                 LC_TENTHS_OFA_MICRON, \\
  326.                                 1)
  327.         CASE 5 ' 0.001 cm.
  328.             FinalX& = Horiz% * Reps% * 0.001 *    \\
  329.                      LENGTHCONVERT(LC_CENTIMETERS,  \\
  330.                                 LC_TENTHS_OFA_MICRON, \\
  331.                                 1)
  332.         CASE 6 ' 1 pt.
  333.             FinalX& = Horiz% * Reps% * 1 *        \\
  334.                      LENGTHCONVERT(LC_POINTS,       \\
  335.                                 LC_TENTHS_OFA_MICRON, \\
  336.                                 1)
  337.  
  338.     END SELECT
  339.     SELECT CASE VertUnit%
  340.     
  341.         CASE 1 ' 1 in.
  342.             FinalY& = Vert% * Reps% * 1 *         \\
  343.                      LENGTHCONVERT(LC_INCHES,       \\
  344.                                    LC_TENTHS_OFA_MICRON, \\
  345.                                 1)
  346.         CASE 2 ' 1/36 in.
  347.             FinalY& = Vert% * Reps% * (1/36) *    \\
  348.                      LENGTHCONVERT(LC_INCHES,       \\
  349.                                    LC_TENTHS_OFA_MICRON, \\
  350.                                 1)
  351.         CASE 3 ' 0.001 in.
  352.             FinalY& = Vert% * Reps% * 0.001 * \\
  353.                      LENGTHCONVERT(LC_INCHES,       \\
  354.                                    LC_TENTHS_OFA_MICRON, \\
  355.                                 1)
  356.         CASE 4 ' 1 cm.
  357.             FinalY& = Vert% * Reps% * 1 *         \\
  358.                      LENGTHCONVERT(LC_CENTIMETERS,  \\
  359.                                 LC_TENTHS_OFA_MICRON, \\
  360.                                 1)
  361.         CASE 5 ' 0.001 cm.
  362.             FinalY& = Vert% * Reps% * 0.001 *     \\
  363.                      LENGTHCONVERT(LC_CENTIMETERS,  \\
  364.                                 LC_TENTHS_OFA_MICRON, \\
  365.                                 1)
  366.         CASE 6 ' 1 pt.
  367.             FinalY& = Vert% * Reps% * 1 *         \\
  368.                      LENGTHCONVERT(LC_POINTS,       \\
  369.                                 LC_TENTHS_OFA_MICRON, \\
  370.                                 1)
  371.  
  372.     END SELECT
  373.  
  374.     IF (FinalX& > AvailableX&) OR (FinalY& > AvailableY&) THEN
  375.         ReturnVal% = MESSAGEBOX("You will go very far off the page with the values you have chosen." + \\
  376.                                 NL2 + "Please choose a smaller number of repetitions or smaller offsets and try again.", \\
  377.                             TITLE_ERRORBOX$, MB_OK_ONLY)
  378.         ValidateInput = FALSE
  379.         EXIT FUNCTION
  380.     ENDIF
  381.  
  382.     ValidateInput = TRUE
  383.     
  384.     VI_End:
  385.     EXIT FUNCTION
  386.     
  387. VIGeneralError:
  388.     ERRNUM = 0
  389.     ValidateInput = FALSE
  390.     RESUME AT VI_End
  391.  
  392. END FUNCTION
  393.  
  394. '********************************************************************
  395. '
  396. '    Name:    DoOperation (subroutine)
  397. '
  398. '    Action:    Actually performs the multiple duplication or cloning
  399. '              operation.
  400. '
  401. '    Params:    OperationType - Clone or duplicate?
  402. '            Reps          - The number of repetitions.
  403. '            Horiz         - The Horizontal offset distance.
  404. '            Vert          - The vertical offset distance.
  405. '            HorizUnit     - What unit is Horiz?
  406. '            VertUnit      - What unit is Vert? 
  407. '
  408. '    Returns:    Nothing.
  409. '
  410. '    Comments:    Propagates any errors encountered, so it would
  411. '              be wise to call this subroutine within an error-
  412. '              handling block.
  413. '
  414. '********************************************************************
  415. SUB DoOperation(OperationType AS INTEGER,                    \\
  416.               Reps AS INTEGER,                            \\
  417.              Horiz AS INTEGER,                            \\
  418.              Vert AS INTEGER,                            \\
  419.              HorizUnit AS INTEGER,                        \\
  420.              VertUnit AS INTEGER)
  421.  
  422.     DIM InitialXPos AS LONG ' The selected object(s)' X coordinate.
  423.     DIM InitialYPos AS LONG ' The selected object(s)' Y coordinate.
  424.     DIM NewXPos AS LONG        ' The clone/duplicate's X coordinate.
  425.     DIM NewYPos AS LONG        ' The clone/duplicate's Y coordinate.
  426.     DIM Counter AS INTEGER  ' A counter variable for loops.    
  427.         
  428.     .GetPosition InitialXPos&, InitialYPos&
  429.     
  430.     FOR Counter% = 1 TO Reps
  431.  
  432.         ' Clone or duplicate.
  433.         IF (OperationType% = OPERATION_DUPLICATE) THEN
  434.             .DuplicateObject
  435.         ELSE ' Clone.
  436.             .CloneObject
  437.         ENDIF
  438.  
  439.         ' Determine where the new object should go.
  440.         SELECT CASE HorizUnit
  441.         
  442.             CASE 1 ' 1 in.
  443.                 NewXPos& = InitialXPos& +                 \\
  444.                                     Horiz% * Counter% * 1 *        \\
  445.                          LENGTHCONVERT(LC_INCHES,       \\
  446.                                        LC_TENTHS_OFA_MICRON, \\
  447.                                     1)
  448.             CASE 2 ' 1/36 in.
  449.                 NewXPos& = InitialXPos& +                 \\
  450.                                     Horiz% * Counter% * (1/36) *   \\
  451.                          LENGTHCONVERT(LC_INCHES,       \\
  452.                                        LC_TENTHS_OFA_MICRON, \\
  453.                                     1)
  454.             CASE 3 ' 0.001 in.
  455.                 NewXPos& = InitialXPos& +                 \\
  456.                                     Horiz% * Counter% * 0.001 *    \\
  457.                          LENGTHCONVERT(LC_INCHES,       \\
  458.                                        LC_TENTHS_OFA_MICRON, \\
  459.                                     1)
  460.             CASE 4 ' 1 cm.
  461.                 NewXPos& = InitialXPos& +                 \\
  462.                          Horiz% * Counter% * 1 *        \\
  463.                          LENGTHCONVERT(LC_CENTIMETERS,  \\
  464.                                     LC_TENTHS_OFA_MICRON, \\
  465.                                     1)
  466.             CASE 5 ' 0.001 cm.
  467.                 NewXPos& = InitialXPos& +                 \\
  468.                          Horiz% * Counter% * 0.001 *    \\
  469.                          LENGTHCONVERT(LC_CENTIMETERS,  \\
  470.                                     LC_TENTHS_OFA_MICRON, \\
  471.                                     1)
  472.             CASE 6 ' 1 pt.
  473.                 NewXPos& = InitialXPos& +                 \\
  474.                          Horiz% * Counter% * 1 *        \\
  475.                          LENGTHCONVERT(LC_POINTS,       \\
  476.                                     LC_TENTHS_OFA_MICRON, \\
  477.                                     1)
  478.  
  479.         END SELECT
  480.         SELECT CASE VertUnit
  481.         
  482.             CASE 1 ' 1 in.
  483.                 NewYPos& = InitialYPos& +                 \\
  484.                                     Vert% * Counter% * 1 *         \\
  485.                          LENGTHCONVERT(LC_INCHES,       \\
  486.                                        LC_TENTHS_OFA_MICRON, \\
  487.                                     1)
  488.             CASE 2 ' 1/36 in.
  489.                 NewYPos& = InitialYPos& +                 \\
  490.                                     Vert% * Counter% * (1/36) *    \\
  491.                          LENGTHCONVERT(LC_INCHES,       \\
  492.                                        LC_TENTHS_OFA_MICRON, \\
  493.                                     1)
  494.             CASE 3 ' 0.001 in.
  495.                 NewYPos& = InitialYPos& +                 \\
  496.                                     Vert% * Counter% * 0.001 *     \\
  497.                          LENGTHCONVERT(LC_INCHES,       \\
  498.                                        LC_TENTHS_OFA_MICRON, \\
  499.                                     1)
  500.             CASE 4 ' 1 cm.
  501.                 NewYPos& = InitialYPos& +                 \\
  502.                          Vert% * Counter% * 1 *         \\
  503.                          LENGTHCONVERT(LC_CENTIMETERS,  \\
  504.                                     LC_TENTHS_OFA_MICRON, \\
  505.                                     1)
  506.             CASE 5 ' 0.001 cm.
  507.                 NewYPos& = InitialYPos& +                 \\
  508.                          Vert% * Counter% * 0.001 *     \\
  509.                          LENGTHCONVERT(LC_CENTIMETERS,  \\
  510.                                     LC_TENTHS_OFA_MICRON, \\
  511.                                     1)
  512.             CASE 6 ' 1 pt.
  513.                 NewYPos& = InitialYPos& +                 \\
  514.                          Vert% * Counter% * 1 *         \\
  515.                          LENGTHCONVERT(LC_POINTS,       \\
  516.                                     LC_TENTHS_OFA_MICRON, \\
  517.                                     1)
  518.  
  519.         END SELECT
  520.  
  521.         ' Put the new object where it should go.
  522.         .SetPosition NewXPos&, NewYPos&
  523.  
  524.     NEXT Counter
  525.  
  526. END SUB
  527.  
  528. END WITHOBJECT
  529.  
  530.