/* Allow commands to return results */ options results /* On error, goto ERROR:. Comment out this line if you wish to */ /* perform your own error checking. */ signal on error 'PROJECT_LOCK' /* BEGIN PROGRAM *************************************************/ /* ++++++++++++++++++++++++++++ */ /* + + */ /* + Spiral ARexx script V1.0 + */ /* + + */ /* + Written by Andrew Elia + */ /* + + */ /* ++++++++++++++++++++++++++++ */ TURNS=100 /* Sets how many rotations are performed */ GROWTH=0.01 /* Controls how fast the spiral widens */ STEPSIZE=15 /* Controls the smoothness of the spiral*/ CENX=10 /* Horizontal centre of spiral */ CENY=10 /* Vertical centre of spiral */ UNIT="cm" /* Sets the default unit */ /* Due to naming bug (?) must name object otherwise can't have more */ /* than one spiral on screen at once */ OBJECT_DESELECT FIRST="None" call addlib("rexxmathlib.library", 0, -30, 0) CONVERT=PI(0)/180 ANG=0 SIZE=0 MYSTRING = "CREATE_BEZIER "||CENX||UNIT||" "||CENY||UNIT Do N=1 To TURNS ANG=ANG+STEPSIZE SIZE=SIZE+GROWTH X=(Sin(ANG*CONVERT)*SIZE)+CENX Y=(Cos(ANG*CONVERT)*SIZE)+CENY MYSTRING = MYSTRING||" L "||X||UNIT||" "||Y||UNIT /* The following IF statement checks to see if the current list of */ /* points in the spiral is too large for ARexx to interpret. If so */ /* the script will draw that part of the spiral and join it on to */ /* any subsequent segments in order to produce a single object. */ If Length(MYSTRING) > 512 Then Do Interpret MYSTRING SECOND = Result If FIRST ~= "None" Then Do OBJECT_DESELECT OBJECT_SELECT FIRST OBJECT_SELECT SECOND OBJECT_JOIN /* Work around - OBJECT_JOIN doesn't return name */ OBJECT_SPECS_GET STEM 'OBJSPECS.' FIRST = OBJSPECS.NAME OBJECT_DESELECT End Else Do FIRST = SECOND End MYSTRING = "CREATE_BEZIER "||X||UNIT||" "||Y||UNIT End End N MYSTRING = MYSTRING||" L "||X||UNIT||" "||Y||UNIT /* Joins the last two parts of the spiral together to form one object */ Interpret MYSTRING SECOND = Result OBJECT_DESELECT OBJECT_SELECT FIRST OBJECT_SELECT SECOND OBJECT_JOIN /* END PROGRAM ***************************************************/ 'PROJECT_UNLOCK' exit /* On ERROR */ ERROR: 'PROJECT_UNLOCK' /* If we get here, either an error occurred with the command's */ /* execution or there was an error with the command itself. */ /* In the former case, rc2 contains the error message and in */ /* the latter, rc2 contains an error number. SIGL contains */ /* the line number of the command which caused the jump */ /* to ERROR: */ if datatype(rc2,'NUMERIC') == 1 then do /* See if we can describe the error with a string */ select when rc2 == 103 then err_string = "ERROR 103, "||, "out of memory at line "||SIGL when rc2 == 114 then err_string = "ERROR 114, "||, "bad command template at line "||SIGL when rc2 == 115 then err_string = "ERROR 115, "||, "bad number for /N argument at line "||SIGL when rc2 == 116 then err_string = "ERROR 116, "||, "required argument missing at line "||SIGL when rc2 == 117 then err_string = "ERROR 117, "||, "value after keywork missing at line "||SIGL when rc2 == 118 then err_string = "ERROR 118, "||, "wrong number of arguments at line "||SIGL when rc2 == 119 then err_string = "ERROR 119, "||, "unmatched quotes at line "||SIGL when rc2 == 120 then err_string = "ERROR 120, "||, "line too long at line "||SIGL when rc2 == 236 then err_string = "ERROR 236, "||, "unknown command at line "||SIGL otherwise err_string = "ERROR "||rc2||", at line "||SIGL end end else if rc2 == 'RC2' then do err_string = "ERROR in command at line "||SIGL end else do err_string = rc2||", line "||SIGL end req_message TEXT '"'err_string'"' exit