Macro problem

Hello,

a few months ago I started to read Joachim de Ravenbel's macro introduction. Now I have to draw the same thing a few times and I thought: Try to write a macro! Hm, of course it doesn't work, but I have no idea why.
Ok, the macro should draw spokes around a point selected by the user. Also the amount and length of the spokes can be entered. Here is the macro:

MACRO SPOKE
SAVESETTINGS
GN varNumber ^DNumber of spokes:
IFERR MacroFail
GV varLength ^DLength of spokes:
IFERR MacroFail
GP varPosition ^DSelect center of spoke:
IFERR MacroFail
GN varAngle 360/varNumber
GN Index 0
:Loop
IFZ Index-varNumber LoopDone
GP varPositionNew ref varPosition <90-(Index*varAngle),varLength
LINE varPosition varPositionNew
GN Index Index+1
Go Loop
:LoopDone
:MacroFail
GETSETTINGS
ENDM

I don't know if CC3 expects ints or floats for point constructs. I've tested both with the same result: the first line will be drawn, then an error is shown.
Could anyone please help and tell me what is wrong?

Thanks in advance
Torsten

Comments

  • edited April 2010
    Hi Torsten

    Try the following :

    LINE varPosition varPositionNew;

    The Line command requires a semicolon to end.

    Works fine with it.

    JdR
  • Hello Joachim,

    thank you very much for the fast response. It was the missing semicolon, a mistake you just make once. The macro works as it should now.
    And thank you again for the great macro introduction tutorials, without them I would have never tried.

    Torsten
  • edited April 2010
    You're welcome :)

    By the way, macros (and CC3) work fine with floats.
    You can freely use

    GV varAngle 360/varNumber

    instead of GN, especially if you want a number of lines that doesn't divide 360 (ie 7,11,13...)

    Note also that the 90-(Index*varAngle) makes the first line always vertical. Should you need it to be horizontal, simply use Index*varAngle.

    JdR
  • Thanks for the hint with the floats. It was intended to start at 90°. It is easier to change this, when you know the function and especially the syntax are correct :) I've added a user input to set the starting angle.
Sign In or Register to comment.