REVO2700 Tell Turtles X;local angl,penDown,x,y global radPerDeg,degPerRad,noDraw,waittime,x0,y0 local x1,y1,A1,gpoints,tObject,tGraphic,labelCount --You may be puzzle by "drag from 0,0 to 0,0" in the handlers below, and "set the Lockscreen to true" --Don't ask. on back temp forward -temp end back on bk temp back temp end bk on centeredCircle r set the style of the templateGraphic to oval if there is no grc "turtleCircle" then create graphic "turtleCircle" set the opaque of grc "turtleCircle" to false set the rect of grc "turtleCircle" to x0-r,y0-r,x0+r,y0+r end centeredCircle function commaFormat pNum put pNum mod 1 into remainder delete char 1 of remainder put trunc(pNum) into pNum put the number of chars in pNum into n repeat with i = 1 to trunc((n-1)/3) put comma after char n - 3*i of pNum end repeat return pNum& remainder end commaformat --function getTheObject who -- put theControls() into tList -- put "" into results -- repeat for each line tLine in tList--with i = 1 to the number of lines in tList -- if who is in tLine and "grc" is not in tLine then --line i of tList then -- put tLine into results--line i of tList into results -- exit repeat -- end if -- end repeat -- put results into tObject -- put quote before word 2 of tObject -- put quote after tObject -- return tObject --end getTheObject function fact n put 1 into results repeat with i = 1 to n multiply results by i end repeat return results end fact on startTurtle tObject put round(the width of this stack/2) into x0 put round(the height of this stack/2) into y0 -- ask "Who to tell?" with "Turtle" put "graphic" &&tObject into tObject --put tObject put 1 into labelCount --put word 2 of tObject & "grc" into tGraphic --replace quote with "" in tGraphic if there is no tObject then set the style of the templateGraphic to "line" create grc word 2 of tObject end if set the opaque of tObject to false --set the style of the templateGraphic to "line" if the style of tObject is not "line" then set the style of tObject to "line" end if set the px of tObject to 0 set the py of tObject to 0 set the pPenDown of tObject to true set the pAngle of tObject to 0 set the pPoints of tObject to x0,y0 & return end startTurtle drawAndMove end startTurtle on st temp startTurtle temp end st on tellColor tColor set the forecolor of tObject to tcolor end tellColor function intersection p1,p2,pp1,pp2 put item 1 of p1 into x1 put item 2 of p1 into y1 put item 1 of p2 into x2 put item 2 of p2 into y2 put item 1 of pp1 into xp1 put item 2 of pp1 into yp1 put item 1 of pp2 into xp2 put item 2 of pp2 into yp2 if x1 = x2 or xp1 = xp2 then if x1 = x2 then return x1&comma&yp2 + (x1-xp2)*(yp2-yp1)/(xp2-xp1) else return xp2&comma& y2 + (xp1-x2)*(y2-y1)/(x2-x1) end if end if put yp2 - y2 + x2*(y2-y1)/(x2 - x1) - xp2*(yp2 - yp1)/(xp2 - xp1) into numerator put ((y2 - y1)/(x2 - x1) -(yp2 - yp1)/(xp2-xp1)) into denom put numerator / denom into x put y2 + (x-x2) *(y2-y1)/(x2-x1) into y return x & comma & y end intersection on setHome xx,yy get the paramcount if it is 1 then put item 2 of xx into yy put item 1 of xx into xx end if put (the width of this stack)/2 + xx into x0 put (the height of this stack)/2 - yy into y0 pu --home pd end setHome on home setxy 0,0 set the pAngle of tObject to 0 end home function log x return ln(x)/ln(10) end log on cleanP set the pPoints of tObject to "" end cleanP on cleanG who put who into temp get the paramcount if it is 0 then if there is a grc "turtleCircle" then delete grc "turtleCircle" repeat with i = 1 to the number of controls put the name of control i into tName if word 1 of tName is "graphic" then set the points of tName to "" end repeat else put "grc" && who into tObject set the pPoints of tObject to "" set the points of tObject to "" end if end cleanG on clearLabels who lock screen get the paramcount if it is 0 then repeat with i = the number of fields down to 1 if "label" is in the name of field i then delete field i end repeat end if if it is 1 then repeat with i = the number of fields down to 1 if "who" is in the name of field i then delete field i end repeat end if unlock screen end clearLabels on cleanL who get the paramcount if it is 0 then clearLabels else cleanLabels who end cleanL on cleanT who put who & "grc" into tGraphic if there is a grc tGraphic then set the points of grc tGraphic to "" end cleanT on cleanText ct end cleanText on ct if there is a field "data" then put "" into field "data" end ct function perpBisector p1,p2 breakpoint pu setXY p1 seth toward( p2) fd .5*distancePt (p2) rt 90 put point into temp1 put item 1 of temp1 into item 1 of temp put item 2 of temp1 into item 2 of temp put heading() into item 3 of temp pd return temp end perpBisector on clean ct lock screen repeat until the number of images is 0 delete image 1 end repeat put 1 into i repeat while i <= the number of fields if "fieldLabel" is in word 2 of the name of field i then delete field i else add 1 to i end repeat unlock screen end clean on incXY dx,dy -- put the px of tObject into x -- put the py of tObject into y put the pPoints of tObject into gPoints if the pPendown of tObject is true then put round (x0 +the px of tObject +dx) &comma &round(y0 -the py of tObject - dy)& return after gPoints else put return & round (x0 +the px of tObject +dx) &comma &round(y0 - the py of tObject - dy)& return after gPoints end if set the px of tObject to the px of tObject + dx set the py of tObject to the py of tObject + dy set the pPoints of tObject to gPoints --set the points of grc tGraphic to gPoints drawAndMove end incXY on setxy xnew,ynew get the paramCount if it = 1 then put item 2 of xnew into ynew put item 1 of xnew into xnew end if set the px of tObject to xnew set the py of tObject to ynew put the pPoints of tObject into gPoints put round(the px of tObject +x0)&comma& round(y0 - the py of tObject) into tLoc if the pPendown of tObject is true then --put truncItems(tLoc) into tLoc put tLoc & return after gPoints else put return & tloc & return after gPoints end if set the pPoints of tObject to gPoints DrawAndMove --set the lockscreen to false end setxy function truncItems tItem return round(item 1 of tItem)& comma&round(item 2 of tItem) end truncItems on setRA tRadius, tAngle put tRadius*cosine(tAngle) into tx put tRadius*sine(tAngle) into ty setXY tX,tY end setRA on drawAndMOve set the points of tObject to the pPoints of tObject wait 0 --set the points of graphic tGraphic to the pPoints of tObject --set the loc of tObject to round(x0 +the px of tObject)&comma&round(y0-the py of tObject) end drawAndMOve on setHeading temp seth temp end setHeading on drawTurtle end drawTurtle on seth anglnew set the pAngle of tObject to anglnew --drawTurtle end seth on left dangl lt dangl end left on right dangl rt dangl end right on rt dangl set the pAngle of tObject to the pAngle of tObject - dangl --drawTurtle end rt on lt dangl set the pAngle of tObject to the pAngle of tObject + dangl end lt on forward distance put distance * cos(radPerDeg * the pAngle of tObject) into dx put distance * sin(radPerDeg * the pAngle of tObject) into dy set the px of tObject to the px of tObject + dx set the py of tObject to the py of tObject + dy put the pPoints of tObject into gPoints put round(the px of tObject +x0)&comma&round(y0- the py of tObject) into tMouseLoc if the pPenDown of tObject is true then put tMouseLoc &return after gPoints else put return & round(the px of tObject+x0)&comma&round(-the py of tObject+y0)& return after gPoints end if set the points of tObject to gPoints set the pPoints of tObject to gPoints wait 0 --set the loc of tObject to tMouseLoc end forward on fd temp forward temp end fd on pu set the pPenDown of tObject to false end pu on penUp pu end penUp on penDown pd end penDown on pd set the pPendown of tObject to true end pd function toward xtemp,ytemp get the paramCount if it is 1 then put item 2 of xtemp into ytemp put item 1 of xtemp into xtemp end if put ytemp - y into dy put xtemp - x into dx if dx = 0 then if dy > 0 then return 90 else return 90 + 180 end if if dy = 0 then if dx > 0 then return 0 else return 180 end if put degPerRad * atan(abs(dy) / abs(dx)) into angl if dy > 0 then if dx > 0 then return angl else return 180 - angl end if if dx > 0 then return 360 - angl else return 180 + angl end if end toward function direction xtemp,ytemp put the px of tObject into x put the py of tObject into y get the paramCount if it is 1 then put item 2 of xtemp into ytemp put item 1 of xtemp into xtemp end if put ytemp - y into dy put xtemp - x into dx if dx = 0 then if dy > 0 then return 90 else return 90 + 180 end if if dy = 0 then if dx > 0 then return 0 else return 180 end if put degPerRad * atan(abs(dy) / abs(dx)) into tAngl if dy > 0 then if dx > 0 then return tAngl else return 180 - tAngl end if if dx > 0 then return 360 - tAngl else return 180 + tAngl end if end direction function direction2 xtemp,ytemp get the paramCount if it is 1 then put item 2 of xtemp into ytemp put item 1 of xtemp into xtemp end if put ytemp - y into dy put xtemp - x into dx put arctangent2(dy,dx) into tAngle if tAngle < 0 then return 360 + tAngle else return tAngle end direction2 function xycor2 return round(the px of tObject) & comma & round(the py of tObject) end xycor2 function xycor return (the px of tObject) & comma & (the py of tObject) end xycor function sci pNum,sigFigures if pNum < 0 then put "-" into sign else put empty into sign put abs(pNum) into pNum if sigFigures is empty then put 3 into sigFigures --Default significant figures. put 0 into count if pNum >= 1 then repeat until pNum < 10 divide pNum by 10 add 1 to count end repeat put round((10^(sigFigures-1))*pNum)/10^(sigFigures-1) into pNum return sign & (char 1 to sigFigures + 1 of pNum) &"*10^" & count end if if pNum < 1 then repeat until pNum >= 1 multiply pNum by 10 add 1 to count end repeat end if return sign & (char 1 to sigFigures + 1 of pNum) & "*10^-" & count end sci function xcor return the px of tObject end xcor function ycor return the py of tObject end ycor function randomInRange b,t return random(t-b+1) + b-1 end randomInRange on setx xnew setxy xnew, the py of tObject end setx on sety ynew setxy the px of tObject, ynew end sety on setColor tColor set the forecolor of tObject to tColor end setColor on setSize tSize set the lineSize of tObject to tSize end setSize on setArrow tCondition set the endArrow of tObject to tCOndition end setArrow function distance xtemp,ytemp get the paramCount if it = 1 then put item 2 of xtemp into ytemp put item 1 of xtemp into xtemp end if return sqrt ((the px of tObject -xtemp)^2 + (the py of tObject-ytemp)^2) end distance function heading put the pAngle of tObject into tempAngle --set the pAngle of tObject to the pAngle of tObject - dangl repeat while tempAngle >360 subtract 360 from tempAngle end repeat repeat while tempAngle < 0 add 360 to tempAngle end repeat return tempAngle end heading on label inputText lock screen put the tool into tTool choose the browse tool set the textstyle of the templateField to "bold" set the style of the templateField to "transparent" set the textAlign of templateField to center --set the dontWrap of templateField to true put "fieldLabel" & labelCount into nField if there is no field nField then create field nField add 1 to labelCount put inputText into field nField set the loc of field nField to turtlePtToMousePt(xycor()) set the width of field nField to the formattedwidth of field nField set the height of field nField to 24--the formattedHeight of field nField set the tool to tTool unlock screen end label function mouseToTurtle pt put round(-x0 + item 1 of pt) into item 1 of temp put round( y0 - item 2 of pt) into item 2 of temp return temp end mouseToTurtle function mousePtToTurtlePt pt return mouseToTurtle(pt) end mousePtToTurtlePt function mpttp pt return mouseToTUrtle(pt) end mpttp function turtleToMouse pt put round(x0 + item 1 of pt) into item 1 of temp put round(y0 - item 2 of pt) into item 2 of temp return temp end turtleToMouse function tptmp pt return turtleToMouse(pt) end tptmp function turtlePtToMousePt pt return turtleToMouse(pt) end turtlePtToMousePt function clickPoint set the cursor to cross wait until mouseClick() --Wait for the mouse click. return mousePtToTurtlePt(mouseLoc()) --Return the mouse coordinates converted to turtle coordinates. end clickPoint on preopenStack global waittime,degPerRad,RadPerDeg,x0,y0 set the style of this stack to "toplevel" put 0 into waittime --clean set the grid to false put 180/ pi into degPerRad put pi/180 into radPerDeg put (the width of this card)/2 into x0 put (the height of this card)/2 into y0 put degPerRad, x0,y0 into msg box choose the browse tool end preopenStack function sine a return sin(radPerDeg* a) end sine function cosine a return cos(radPerDeg*a) end cosine function tangent a return tan(radPerDeg*a) end tangent function arcsine a return atan(a/sqrt(1-a*a))/radPerDeg end arcsine function arcTangent a return atan(a)*degPerRad end arcTangent function arcTangent2 y,x return degPerRad*atan2(y,x) end arcTangent2 function sum list put 0 into theResult repeat with i = 1 to the paramcount add param(i) to theResult end repeat return theResult end sum on pr x set the numberformat to "#.00" if there is a field "data" then put x & return after field "data" end pr on functionKey tKey switch tKey case 8 if the tool is "browse tool" then choose the pointer tool else choose the browse tool end if break case 2 edit the script of this stack break case 3 edit the script of this card break case 5 go to next card break case 4 go to previous card break case 6 ct break end switch end functionKey on tell who put "graphic" && who into tObject end tell function theControls repeat with i = 1 to the number of controls put the name of control i into temp replace quote with empty in temp put temp into line i of results end repeat return results end theControls on tabKey if controlkey() = "down" then if the tool = "pointer tool" then choose browse tool else choose pointer tool else pass tabKey end tabKey f`{o$ UGenevaUGeneva WGeneva0UGenevaWGeneva U W ULucida GrandeW helvetica cREVGeneral scriptChecksum?pm݆GN debugObjectsbutton id 1878 of card id 1872 of stack "Tell Turtles" button id 1884 of card id 1872 of stack "Tell Turtles" button id 1949 of card id 1872 of stack "Tell Turtles" button id 1949 of card id 1872 of stack "UniformLine" button id 1984 of card id 1982 of stack "UniformLine" breakPoints handlerList\back bk centeredCircle commaFormat fact startTurtle st tellColor intersection setHome home log cleanP cleanG clearLabels cleanL cleanT cleanText ct perpBisector clean incXY setxy truncItems setRA drawAndMOve setHeading drawTurtle seth left right rt lt forward fd pu penUp penDown pd toward direction direction2 xycor2 xycor sci xcor ycor randomInRange setx sety setColor setSize setArrow distance heading label mouseToTurtle mousePtToTurtlePt mpttp turtleToMouse tptmp turtlePtToMousePt clickPoint preopenStack sine cosine tangent arcsine arcTangent arcTangent2 sum pr functionKey tell theControls tabKeyscriptSelectionchar 11281 to 11280 bookmarks tempScript prevHandlerarcsinestackfileversion2.7scriptb)

local angl,penDown,x,y

global radPerDeg,degPerRad,noDraw,waittime,x0,y0

local x1,y1,A1,gpoints,tObject,tGraphic,labelCount

--You may be puzzle by "drag from 0,0 to 0,0" in the handlers below, and "set the Lockscreen to true"

--Don't ask.

on back temp

forward -temp

end back

on bk temp

back temp

end bk

on centeredCircle r

set the style of the templateGraphic to oval

if there is no grc "turtleCircle" then create graphic "turtleCircle"

set the opaque of grc "turtleCircle" to false

set the rect of grc "turtleCircle" to x0-r,y0-r,x0+r,y0+r

end centeredCircle

function commaFormat pNum

put pNum mod 1 into remainder

delete char 1 of remainder

put trunc(pNum) into pNum

put the number of chars in pNum into n

repeat with i = 1 to trunc((n-1)/3)

put comma after char n - 3*i of pNum

end repeat

return pNum& remainder

end commaformat

--function getTheObject who

-- put theControls() into tList

-- put "" into results

-- repeat for each line tLine in tList--with i = 1 to the number of lines in tList

-- if who is in tLine and "grc" is not in tLine then --line i of tList then

-- put tLine into results--line i of tList into results

-- exit repeat

-- end if

-- end repeat

-- put results into tObject

-- put quote before word 2 of tObject

-- put quote after tObject

-- return tObject

--end getTheObject

function fact n

put 1 into results

repeat with i = 1 to n

multiply results by i

end repeat

return results

end fact

on startTurtle tObject

put round(the width of this stack/2) into x0

put round(the height of this stack/2) into y0

-- ask "Who to tell?" with "Turtle"

put "graphic" &&tObject into tObject

--put tObject

put 1 into labelCount

--put word 2 of tObject & "grc" into tGraphic

--replace quote with "" in tGraphic

if there is no tObject then

set the style of the templateGraphic to "line"

create grc word 2 of tObject

end if

set the opaque of tObject to false

--set the style of the templateGraphic to "line"

if the style of tObject is not "line" then

set the style of tObject to "line"

end if

set the px of tObject to 0

set the py of tObject to 0

set the pPenDown of tObject to true

set the pAngle of tObject to 0

set the pPoints of tObject to x0,y0 & return

end startTurtle

drawAndMove

end startTurtle

on st temp

startTurtle temp

end st

on tellColor tColor

set the forecolor of tObject to tcolor

end tellColor

function intersection p1,p2,pp1,pp2

put item 1 of p1 into x1

put item 2 of p1 into y1

put item 1 of p2 into x2

put item 2 of p2 into y2

put item 1 of pp1 into xp1

put item 2 of pp1 into yp1

put item 1 of pp2 into xp2

put item 2 of pp2 into yp2

if x1 = x2 or xp1 = xp2 then

if x1 = x2 then

return x1&comma&yp2 + (x1-xp2)*(yp2-yp1)/(xp2-xp1)

else

return xp2&comma& y2 + (xp1-x2)*(y2-y1)/(x2-x1)

end if

end if

put yp2 - y2 + x2*(y2-y1)/(x2 - x1) - xp2*(yp2 - yp1)/(xp2 - xp1) into numerator

put ((y2 - y1)/(x2 - x1) -(yp2 - yp1)/(xp2-xp1)) into denom

put numerator / denom into x

put y2 + (x-x2) *(y2-y1)/(x2-x1) into y

return x & comma & y

end intersection

on setHome xx,yy

get the paramcount

if it is 1 then

put item 2 of xx into yy

put item 1 of xx into xx

end if

put (the width of this stack)/2 + xx into x0

put (the height of this stack)/2 - yy into y0

pu

--home

pd

end setHome

on home

setxy 0,0

set the pAngle of tObject to 0

end home

function log x

return ln(x)/ln(10)

end log

on cleanP

set the pPoints of tObject to ""

end cleanP

on cleanG who

put who into temp

get the paramcount

if it is 0 then

if there is a grc "turtleCircle" then delete grc "turtleCircle"

repeat with i = 1 to the number of controls

put the name of control i into tName

if word 1 of tName is "graphic" then set the points of tName to ""

end repeat

else

put "grc" && who into tObject

set the pPoints of tObject to ""

set the points of tObject to ""

end if

end cleanG

on clearLabels who

lock screen

get the paramcount

if it is 0 then

repeat with i = the number of fields down to 1

if "label" is in the name of field i then delete field i

end repeat

end if

if it is 1 then

repeat with i = the number of fields down to 1

if "who" is in the name of field i then delete field i

end repeat

end if

unlock screen

end clearLabels

on cleanL who

get the paramcount

if it is 0 then

clearLabels

else cleanLabels who

end cleanL

on cleanT who

put who & "grc" into tGraphic

if there is a grc tGraphic then set the points of grc tGraphic to ""

end cleanT

on cleanText

ct

end cleanText

on ct

if there is a field "data" then put "" into field "data"

end ct

function perpBisector p1,p2

breakpoint

pu

setXY p1

seth toward( p2)

fd .5*distancePt (p2)

rt 90

put point into temp1

put item 1 of temp1 into item 1 of temp

put item 2 of temp1 into item 2 of temp

put heading() into item 3 of temp

pd

return temp

end perpBisector

on clean

ct

lock screen

repeat until the number of images is 0

delete image 1

end repeat

put 1 into i

repeat while i <= the number of fields

if "fieldLabel" is in word 2 of the name of field i

then delete field i

else add 1 to i

end repeat

unlock screen

end clean

on incXY dx,dy

-- put the px of tObject into x

-- put the py of tObject into y

put the pPoints of tObject into gPoints

if the pPendown of tObject is true

then

put round (x0 +the px of tObject +dx) &comma &round(y0 -the py of tObject - dy)& return after gPoints

else

put return & round (x0 +the px of tObject +dx) &comma &round(y0 - the py of tObject - dy)& return after gPoints

end if

set the px of tObject to the px of tObject + dx

set the py of tObject to the py of tObject + dy

set the pPoints of tObject to gPoints

--set the points of grc tGraphic to gPoints

drawAndMove

end incXY

on setxy xnew,ynew

get the paramCount

if it = 1 then

put item 2 of xnew into ynew

put item 1 of xnew into xnew

end if

set the px of tObject to xnew

set the py of tObject to ynew

put the pPoints of tObject into gPoints

put round(the px of tObject +x0)&comma& round(y0 - the py of tObject) into tLoc

if the pPendown of tObject is true then

--put truncItems(tLoc) into tLoc

put tLoc & return after gPoints

else

put return & tloc & return after gPoints

end if

set the pPoints of tObject to gPoints

DrawAndMove

--set the lockscreen to false

end setxy

function truncItems tItem

return round(item 1 of tItem)& comma&round(item 2 of tItem)

end truncItems

on setRA tRadius, tAngle

put tRadius*cosine(tAngle) into tx

put tRadius*sine(tAngle) into ty

setXY tX,tY

end setRA

on drawAndMOve

set the points of tObject to the pPoints of tObject

wait 0

--set the points of graphic tGraphic to the pPoints of tObject

--set the loc of tObject to round(x0 +the px of tObject)&comma&round(y0-the py of tObject)

end drawAndMOve

on setHeading temp

seth temp

end setHeading

on drawTurtle

end drawTurtle

on seth anglnew

set the pAngle of tObject to anglnew

--drawTurtle

end seth

on left dangl

lt dangl

end left

on right dangl

rt dangl

end right

on rt dangl

set the pAngle of tObject to the pAngle of tObject - dangl

--drawTurtle

end rt

on lt dangl

set the pAngle of tObject to the pAngle of tObject + dangl

end lt

on forward distance

put distance * cos(radPerDeg * the pAngle of tObject) into dx

put distance * sin(radPerDeg * the pAngle of tObject) into dy

set the px of tObject to the px of tObject + dx

set the py of tObject to the py of tObject + dy

put the pPoints of tObject into gPoints

put round(the px of tObject +x0)&comma&round(y0- the py of tObject) into tMouseLoc

if the pPenDown of tObject is true then

put tMouseLoc &return after gPoints

else

put return & round(the px of tObject+x0)&comma&round(-the py of tObject+y0)& return after gPoints

end if

set the points of tObject to gPoints

set the pPoints of tObject to gPoints

wait 0

--set the loc of tObject to tMouseLoc

end forward

on fd temp

forward temp

end fd

on pu

set the pPenDown of tObject to false

end pu

on penUp

pu

end penUp

on penDown

pd

end penDown

on pd

set the pPendown of tObject to true

end pd

function toward xtemp,ytemp

get the paramCount

if it is 1 then

put item 2 of xtemp into ytemp

put item 1 of xtemp into xtemp

end if

put ytemp - y into dy

put xtemp - x into dx

if dx = 0 then

if dy > 0 then return 90

else return 90 + 180

end if

if dy = 0 then

if dx > 0 then return 0

else return 180

end if

put degPerRad * atan(abs(dy) / abs(dx)) into angl

if dy > 0 then

if dx > 0 then return angl

else return 180 - angl

end if

if dx > 0 then

return 360 - angl

else

return 180 + angl

end if

end toward

function direction xtemp,ytemp

put the px of tObject into x

put the py of tObject into y

get the paramCount

if it is 1 then

put item 2 of xtemp into ytemp

put item 1 of xtemp into xtemp

end if

put ytemp - y into dy

put xtemp - x into dx

if dx = 0 then

if dy > 0 then return 90

else return 90 + 180

end if

if dy = 0 then

if dx > 0 then return 0

else return 180

end if

put degPerRad * atan(abs(dy) / abs(dx)) into tAngl

if dy > 0 then

if dx > 0 then return tAngl

else return 180 - tAngl

end if

if dx > 0 then

return 360 - tAngl

else

return 180 + tAngl

end if

end direction

function direction2 xtemp,ytemp

get the paramCount

if it is 1 then

put item 2 of xtemp into ytemp

put item 1 of xtemp into xtemp

end if

put ytemp - y into dy

put xtemp - x into dx

put arctangent2(dy,dx) into tAngle

if tAngle < 0 then return 360 + tAngle

else return tAngle

end direction2

function xycor2

return round(the px of tObject) & comma & round(the py of tObject)

end xycor2

function xycor

return (the px of tObject) & comma & (the py of tObject)

end xycor

function sci pNum,sigFigures

if pNum < 0 then

put "-" into sign

else put empty into sign

put abs(pNum) into pNum

if sigFigures is empty then put 3 into sigFigures --Default significant figures.

put 0 into count

if pNum >= 1 then

repeat until pNum < 10

divide pNum by 10

add 1 to count

end repeat

put round((10^(sigFigures-1))*pNum)/10^(sigFigures-1) into pNum

return sign & (char 1 to sigFigures + 1 of pNum) &"*10^" & count

end if

if pNum < 1 then

repeat until pNum >= 1

multiply pNum by 10

add 1 to count

end repeat

end if

return sign & (char 1 to sigFigures + 1 of pNum) & "*10^-" & count

end sci

function xcor

return the px of tObject

end xcor

function ycor

return the py of tObject

end ycor

function randomInRange b,t

return random(t-b+1) + b-1

end randomInRange

on setx xnew

setxy xnew, the py of tObject

end setx

on sety ynew

setxy the px of tObject, ynew

end sety

on setColor tColor

set the forecolor of tObject to tColor

end setColor

on setSize tSize

set the lineSize of tObject to tSize

end setSize

on setArrow tCondition

set the endArrow of tObject to tCOndition

end setArrow

function distance xtemp,ytemp

get the paramCount

if it = 1 then

put item 2 of xtemp into ytemp

put item 1 of xtemp into xtemp

end if

return sqrt ((the px of tObject -xtemp)^2 + (the py of tObject-ytemp)^2)

end distance

function heading

put the pAngle of tObject into tempAngle

--set the pAngle of tObject to the pAngle of tObject - dangl

repeat while tempAngle >360

subtract 360 from tempAngle

end repeat

repeat while tempAngle < 0

add 360 to tempAngle

end repeat

return tempAngle

end heading

on label inputText

lock screen

put the tool into tTool

choose the browse tool

set the textstyle of the templateField to "bold"

set the style of the templateField to "transparent"

set the textAlign of templateField to center

--set the dontWrap of templateField to true

put "fieldLabel" & labelCount into nField

if there is no field nField then create field nField

add 1 to labelCount

put inputText into field nField

set the loc of field nField to turtlePtToMousePt(xycor())

set the width of field nField to the formattedwidth of field nField

set the height of field nField to 24--the formattedHeight of field nField

set the tool to tTool

unlock screen

end label

function mouseToTurtle pt

put round(-x0 + item 1 of pt) into item 1 of temp

put round( y0 - item 2 of pt) into item 2 of temp

return temp

end mouseToTurtle

function mousePtToTurtlePt pt

return mouseToTurtle(pt)

end mousePtToTurtlePt

function mpttp pt

return mouseToTUrtle(pt)

end mpttp

function turtleToMouse pt

put round(x0 + item 1 of pt) into item 1 of temp

put round(y0 - item 2 of pt) into item 2 of temp

return temp

end turtleToMouse

function tptmp pt

return turtleToMouse(pt)

end tptmp

function turtlePtToMousePt pt

return turtleToMouse(pt)

end turtlePtToMousePt

function clickPoint

set the cursor to cross

wait until mouseClick() --Wait for the mouse click.

return mousePtToTurtlePt(mouseLoc()) --Return the mouse coordinates converted to turtle coordinates.

end clickPoint

on preopenStack

global waittime,degPerRad,RadPerDeg,x0,y0

set the style of this stack to "toplevel"

put 0 into waittime

--clean

set the grid to false

put 180/ pi into degPerRad

put pi/180 into radPerDeg

put (the width of this card)/2 into x0

put (the height of this card)/2 into y0

put degPerRad, x0,y0 into msg box

choose the browse tool

end preopenStack

function sine a

return sin(radPerDeg* a)

end sine

function cosine a

return cos(radPerDeg*a)

end cosine

function tangent a

return tan(radPerDeg*a)

end tangent

function arcsine a

return atan(a/sqrt(1-a*a))/radPerDeg

end arcsine

function arcTangent a

return atan(a)*degPerRad

end arcTangent

function arcTangent2 y,x

return degPerRad*atan2(y,x)

end arcTangent2

function sum list

put 0 into theResult

repeat with i = 1 to the paramcount

add param(i) to theResult

end repeat

return theResult

end sum

on pr x

set the numberformat to "#.00"

if there is a field "data" then put x & return after field "data"

end pr

on functionKey tKey

switch tKey

case 8

if the tool is "browse tool" then

choose the pointer tool

else

choose the browse tool

end if

break

case 2

edit the script of this stack

break

case 3

edit the script of this card

break

case 5

go to next card

break

case 4

go to previous card

break

case 6

ct

break

end switch

end functionKey

on tell who

put "graphic" && who into tObject

end tell

function theControls

repeat with i = 1 to the number of controls

put the name of control i into temp

replace quote with empty in temp

put temp into line i of results

end repeat

return results

end theControls

on tabKey

if controlkey() = "down" then

if the tool = "pointer tool"

then choose browse tool

else choose pointer tool

else pass tabKey

end tabKey

 Pwon opencard global waittime,degPerRad,RadPerDeg,x0,y0 set the style of this stack to "toplevel" put 0 into waittime --clean set the grid to false put 180/ pi into degPerRad put pi/180 into radPerDeg put (the width of this card)/2 into x0 put (the height of this card)/2 into y0 put degPerRad, x0,y0 into msg box choose the browse tool end opencard {o cREVGeneralscriptChecksum u8 I bookmarks handlerListopencard tempScript prevHandleropencardscriptSelectionchar 360 to 359script

on opencard

global waittime,degPerRad,RadPerDeg,x0,y0

set the style of this stack to "toplevel"

put 0 into waittime

--clean

set the grid to false

put 180/ pi into degPerRad

put pi/180 into radPerDeg

put (the width of this card)/2 into x0

put (the height of this card)/2 into y0

put degPerRad, x0,y0 into msg box

choose the browse tool

end opencard

                  i @{o cREVGeneral bookmarks handlerList tempScript prevHandlerscriptjklmno j New Field 2*@V cREVGeneral revUniqueID 1069177600681 bookmarks handlerList tempScript prevHandlerscript i GThis card defines the main elements in the turtle graphic vocabulary. F .For "Turtle" read "Graphic Line"" throughout. - k New Field 1)`,F cREVGeneral revUniqueID 1069177600682 i 0 Commands [and their abreviations]  !  forward 100 [fd 100]   4Moves the turtle 100 pixels at the current heading. 3 back 100 [bk 100]   9Moves the turtle back 100 pixels at the current heading. 8 right 30 [rt 30]   8Rotates the turtle clockwise through a 30 degree angle. 7 left 30 [lt 30]   ?Rotates the turtle counterclockwise through a 30 degree angle. > setHeading 45 [seth 45]   Directs the turtle to an angle of 45 degrees. (All angles are measured in the usual Cartesian manner, that is counterclockwise from 3 O'clock.)  setX 30   8Moves the turtle horizontally to the coordinate x = 30. 7 setY 40   6Moves the turtle vertically to the coordinate y = 40. 5 setXY 30,40   +Moves the turtle to the coordinates 30,40. * incXY 3,4   IIncreases the x coordinate of the turtle by 3 and the y coordinate by 4. H      l New Field 3)`*Y cREVGeneral revUniqueID 1069177600683 bookmarks handlerList tempScript prevHandlerscript i % Functions   xcor ( )   #Returns the turtles x coordinate. ycor ( )   #Returns the turtles y coordinate. xyCor ( )   4Returns a list of the turtles x and y coordinates. heading ( )   Returns the turtle's heading. #direction (30,40) or toward(30,40)     qReturns the direction of the point 30,40 from the current location of the turtle. It does not rotate the turtle. distance (30,40)   QReturns the distance from the current location of the turtle to the point 30,40. clickPoint ( )    jReturns the x and y coordinates of the point of the mouse click--useful in importing data into a program. Intersection(ax,ay,bx,by)   MReturns the intersection of two lines whose endpoints are ax, ay and bx, by. L m New Field 4)`jc cREVGeneral revUniqueID 1069177600684 bookmarks handlerList tempScript prevHandlerscript i 8 Miscellaneous * * StartTurtle [st] tName   Initiates the turtle (control) with the name tName, giving the control the custom properties of x, y coordinates, heading, pen state (up or down) and graphic points. The associated graphic (trace)is {tName} &"grc"  Tell tName   &Tell the turtle who he is talking to. % home  ;Moves the turtle to the origin and pointing to the right. : setHome 30,40   Sets the home position of the turtle a distance 30 to the right of screen-center, and a distance 40 above screen-center. (It does not move the turtle home.)  cleanG tName   bClears the graphic points but not the graphic. If tName is omitted, it clears all graphic points. a penUp [pu]   MRaises the drawing pen. The turtle will no longer leave a track as he moves. L penDown [pd]   Lowers the drawing pen.  TurtlePtToMousePt  tConverts turtle coordinates, measured from the screen's center, to mouse coordinates, measured from the upper left. s MousePtToTurtlePt  See above.  centeredCircle 5   IDraws a circle, centered about the current turtle position, of radius 5. H Label "x"   TPrints an x (or whatever you place within quotes) at the current turtle location. S sci (num,sig)   xReturns the input num in scientific notation with "sig" significant figures, e.g. sci(312345.67, 3) becomes 3.12*10^5. w commaFormat(num)    bReturns the num with commas delimiting each triplet, i.e. commaFormat(9999999) returns 9,999,999. a SetColor red   BSets the forecolor of the active turtle to red. Must follow Tell. < < SetSize 3  ,Sets the linesize of the active turtle to 3 + SetArrow true  1Sets the end arrow of the active turtle to true. 0 nReturnEp+on mouseUP go to first card end mouseUP +(W cREVGeneralscriptChecksumZE5,9 4/ys bookmarks revUniqueID 1069177600685 handlerListmouseUPscriptSelection char 30 to 29 prevHandler tempScriptscript>

on mouseUP

go to first card

end mouseUP

oField 1)`X  cREVGeneral revUniqueID 1069177600686 i This version allow one to create several line graphic objects and address them individually using the turtle graphic vocabulary. Each turtle has four custom properties: . x and y coordinates, heading, and pen state The x and y Cartesian coordinates are measured relative to the center of the screen, the heading is the traditional polar angle, i.e. due east is 0 degrees and due north 90 degrees. The pen state is either up or down--drawing or not. uTo make the turtle receptive to the Turtle Graphic vocabulary you must first initiate the various turtles with say: startTurtle "redLine" startTurtle "blueLine" ^Now that the custom properties are set, you may begin to address the various turtles with say tell "redLine" {some turtle stuff} tell "blueLine" {some turtle stuff} tell "redLine" {some more turtle stuff} etc. Since the turtle represents a line graphic, you may set the color, line size, and end/start arrow. For example if the turtle's name is "redLine" then you would: . set the forecolor of grc "redLine" to "red" ) set the lineSize of grc "redLine" to 2 , set the endArrow of grc "redLine" to true p `Y Build clockEpon mouseUp --First build the clock hands. startTurtle "tHours" tell "tHours" setColor yellow setSize 6 setArrow true --set the endarrow of grc "tHours" to true --Not Turtle graphics startTurtle "tMinutes" tell "tMinutes" setColor blue setSize 4 setarrow true --set endarrow of grc "tMinutes" to true startTurtle "tSeconds" tell "tSeconds" setColor red setSize 1 setarrow true --set endarrow of grc "tSeconds" to true --Build the clock face startTurtle "face" tell "face" pu setRA 100,0 pd repeat with i = 0 to 359 step 2 setRA 100,i if i mod 30 is 0 then setRA 90,i pu setRA 80,i put (-i/30+15) mod 12 into x if x <> 0 then label x else label 12 end if setRA 100,i pd end repeat --Now run it. setTime end mouseUp on setTime if the shiftKey is down then exit to top lock screen put word 1 of the long time into T set the itemdelimiter to ":" put item 1 of T into h put item 2 of T into m put item 3 of T into s put (h*60*60 + m*60 + s)/(12*60*60)*360 into hAngle put (m*60+s)/(60*60)*360 into mAngle put s/60*360 into sAngle tell "tSeconds" cleanP -- set points to empty. Get ready for new info setRA 0,0 setRA 100, 90 - sAngle tell "tMinutes" cleanP setRA 0,0 setRA 90,90 - mAngle tell "tHours" cleanP setRA 0,0 setRA 60,90 - hAngle put T into field 1 unlock screen send "setTime" to me in 1 sec end setTime Rp cREVGeneral scriptChecksumc5L handlerListmouseUp setTime breakPointsscriptSelectionchar 454 to 453 revUniqueID 1117562035972 bookmarks tempScript prevHandlersetTimescript

on mouseUp

--First build the clock hands.

startTurtle "tHours"

tell "tHours"

setColor yellow

setSize 6

setArrow true

--set the endarrow of grc "tHours" to true --Not Turtle graphics

startTurtle "tMinutes"

tell "tMinutes"

setColor blue

setSize 4

setarrow true

--set endarrow of grc "tMinutes" to true

startTurtle "tSeconds"

tell "tSeconds"

setColor red

setSize 1

setarrow true

--set endarrow of grc "tSeconds" to true

--Build the clock face

startTurtle "face"

tell "face"

pu

setRA 100,0

pd

repeat with i = 0 to 359 step 2

setRA 100,i

if i mod 30 is 0 then

setRA 90,i

pu

setRA 80,i

put (-i/30+15) mod 12 into x

if x <> 0 then

label x

else label 12

end if

setRA 100,i

pd

end repeat

--Now run it.

setTime

end mouseUp

on setTime

if the shiftKey is down then exit to top

lock screen

put word 1 of the long time into T

set the itemdelimiter to ":"

put item 1 of T into h

put item 2 of T into m

put item 3 of T into s

put (h*60*60 + m*60 + s)/(12*60*60)*360 into hAngle

put (m*60+s)/(60*60)*360 into mAngle

put s/60*360 into sAngle

tell "tSeconds"

cleanP -- set points to empty. Get ready for new info

setRA 0,0

setRA 100, 90 - sAngle

tell "tMinutes"

cleanP

setRA 0,0

setRA 90,90 - mAngle

tell "tHours"

cleanP

setRA 0,0

setRA 60,90 - hAngle

put T into field 1

unlock screen

send "setTime" to me in 1 sec

end setTime

Field @S cREVGeneral revUniqueID 1117563863727  2:09:07 Erase clockEpon mouseUp repeat the number of lines in the pendingmessages cancel item 1 of last line of the pendingMessages end repeat repeat with i = 1 to the number of graphics delete grc 1 end repeat cleanL end mouseUp RP cREVGeneralscriptChecksum( Ԇ+Kp)fc revUniqueID 1117582336051 bookmarks handlerListmouseUp tempScript prevHandlermouseUpscriptSelectionchar 133 to 132script

on mouseUp

repeat the number of lines in the pendingmessages

cancel item 1 of last line of the pendingMessages

end repeat

repeat with i = 1 to the number of graphics

delete grc 1

end repeat

cleanL

end mouseUp

 Show vocabularyEp*on mouseUp go to next card end mouseUp h~ cREVGeneral scriptChecksumi>ln|A$ handlerListmouseUp breakPointsscriptSelection char 29 to 28 revUniqueID 1205512128004 bookmarks tempScript prevHandlermouseUpscript

on mouseUp

go to next card

end mouseUp

 tHours@KyellowT8px 54.181387py 25.775517 pPenDowntruepPoints446,312 500,286 pAngle08 cREVGeneral revUniqueID 1205512370907 tMinutes@KbluecNpx 73.452383py 52.007186 pPenDowntruepPoints446,312 519,260 pAngle08 cREVGeneral revUniqueID 1205512370927 tSeconds@KredSZpx 66.913061py 74.314483 pPenDowntruepPoints446,312 513,238 pAngle08 cREVGeneral revUniqueID 1205512370951 faceKYpx100py-0 pPenDowntruepPoints K446,312 546,312 546,312 536,312 526,312 546,312 546,309 546,309 546,305 546,305 545,302 545,302 545,298 545,298 544,295 544,295 544,291 544,291 543,288 543,288 542,284 542,284 541,281 541,281 540,278 540,278 539,275 539,275 537,271 537,271 536,268 536,268 534,265 534,265 533,262 524,267 515,272 533,262 531,259 531,259 529,256 529,256 527,253 527,253 525,250 525,250 523,248 523,248 520,245 520,245 518,243 518,243 515,240 515,240 513,238 513,238 510,235 510,235 508,233 508,233 505,231 505,231 502,229 502,229 499,227 499,227 496,225 491,234 486,243 496,225 493,224 493,224 490,222 490,222 487,221 487,221 483,219 483,219 480,218 480,218 477,217 477,217 474,216 474,216 470,215 470,215 467,214 467,214 463,214 463,214 460,213 460,213 456,213 456,213 453,212 453,212 449,212 449,212 446,212 446,222 446,232 446,212 443,212 443,212 439,212 439,212 436,213 436,213 432,213 432,213 429,214 429,214 425,214 425,214 422,215 422,215 418,216 418,216 415,217 415,217 412,218 412,218 409,219 409,219 405,221 405,221 402,222 402,222 399,224 399,224 396,225 401,234 406,243 396,225 393,227 393,227 390,229 390,229 387,231 387,231 384,233 384,233 382,235 382,235 379,238 379,238 377,240 377,240 374,243 374,243 372,245 372,245 369,248 369,248 367,250 367,250 365,253 365,253 363,256 363,256 361,259 361,259 359,262 368,267 377,272 359,262 358,265 358,265 356,268 356,268 355,271 355,271 353,275 353,275 352,278 352,278 351,281 351,281 350,284 350,284 349,288 349,288 348,291 348,291 348,295 348,295 347,298 347,298 347,302 347,302 346,305 346,305 346,309 346,309 346,312 356,312 366,312 346,312 346,315 346,315 346,319 346,319 347,322 347,322 347,326 347,326 348,329 348,329 348,333 348,333 349,336 349,336 350,340 350,340 351,343 351,343 352,346 352,346 353,349 353,349 355,353 355,353 356,356 356,356 358,359 358,359 359,362 368,357 377,352 359,362 361,365 361,365 363,368 363,368 365,371 365,371 367,374 367,374 369,376 369,376 372,379 372,379 374,381 374,381 377,384 377,384 379,386 379,386 382,389 382,389 384,391 384,391 387,393 387,393 390,395 390,395 393,397 393,397 396,399 401,390 406,381 396,399 399,400 399,400 402,402 402,402 405,403 405,403 409,405 409,405 412,406 412,406 415,407 415,407 418,408 418,408 422,409 422,409 425,410 425,410 429,410 429,410 432,411 432,411 436,411 436,411 439,412 439,412 443,412 443,412 446,412 446,402 446,392 446,412 449,412 449,412 453,412 453,412 456,411 456,411 460,411 460,411 463,410 463,410 467,410 467,410 470,409 470,409 474,408 474,408 477,407 477,407 480,406 480,406 483,405 483,405 487,403 487,403 490,402 490,402 493,400 493,400 496,399 491,390 486,381 496,399 499,397 499,397 502,395 502,395 505,393 505,393 508,391 508,391 510,389 510,389 513,386 513,386 515,384 515,384 518,381 518,381 520,379 520,379 523,376 523,376 525,374 525,374 527,371 527,371 529,368 529,368 531,365 531,365 533,362 524,357 515,352 533,362 534,359 534,359 536,356 536,356 537,353 537,353 539,349 539,349 540,346 540,346 541,343 541,343 542,340 542,340 543,336 543,336 544,333 544,333 544,329 544,329 545,326 545,326 545,322 545,322 546,319 546,319 546,315 546,315 546,312 536,312 526,312 546,312 pAngle08"8"888"8"5"5"1"1!.!.!*!* ' ' # #            ހ~~{{yyvvttqqoommkkiigp ygf f d d ccaa``__^^] ] \#\#\'\'[*[*[.[.Z1Z1Z5Z5Z8d8n8Z8Z;Z;Z?Z?[B[B[F[F\I\I\M\M]P]P^T^T_W_W`Z`Za]a]cacaddddfgfggjpey`gjimimkpkpmsmsovovqxqxt{t{v}v}yy{{~~}}}}{{ x x v vssppmmj e`jggddaa]]ZZWWTTPP M M I I!F!F!B!B"?"?";";"888"8 cREVGeneral revUniqueID 1205512370975 fieldLabel1+, cREVGeneral revUniqueID 1205512371020  3  fieldLabel2+ cREVGeneral revUniqueID 1205512371328  2  fieldLabel3+ cREVGeneral revUniqueID 1205512371494  1  fieldLabel4+  cREVGeneral revUniqueID 1205512371671  12  fieldLabel5+  cREVGeneral revUniqueID 1205512371848  11  fieldLabel6+i  cREVGeneral revUniqueID 1205512372014  10  fieldLabel7+b, cREVGeneral revUniqueID 1205512372200  9  fieldLabel8+mT cREVGeneral revUniqueID 1205512372401  8  fieldLabel9+q cREVGeneral revUniqueID 1205512372601  7  fieldLabel10+| cREVGeneral revUniqueID 1205512372806  6  fieldLabel11+q cREVGeneral revUniqueID 1205512373006  5  fieldLabel12+T cREVGeneral revUniqueID 1205512373203  4  fieldLabel13+, cREVGeneral revUniqueID 1205512373415  3