REVO2700 Temperature x Won preopenstack --set the defaultmenubar to the short name of group "A paradox" of stack "A paradox in time" set the menubar of this stack to "" end preopenstack on openstack --set the defaultmenubar to the short name of group "A paradox" of stack "A paradox in time" set the menubar of this stack to "" end openstack v|e 7749,302 741,305 719,308 734,310 748,303 764,300 780,299 QdotHome 740,315Path 6742,310 741,306 719,308 734,310 748,30 764,300 780,299pClass !55,6,-3,2 303,100,2,3 320,127,3,6 W Geneva $ W Geneva W Times U Times U Geneva W Geneva U Geneva W Geneva U New York W New York W New York W Arial W Times W Geneva W Geneva U Times U Times U Times W Times U Times U Times U ms sans serif U Geneva U Times U Geneva U Lucida Grande @U Times PU Times QDa8 cREVGeneral debugObjects button id 1075 of card id 1057 of stack "Pardox in time" button id 1888 of card id 1965 of stack "Pardox in time" graphic id 1899 of card id 1965 of stack "Pardox in time" group id 1983 of card id 1965 of stack "Pardox in time" graphic id 1969 of card id 1965 of stack "Pardox in time" graphic id 1968 of card id 1965 of stack "Pardox in time" field id 2139 of card id 1965 of stack "Paradox in time applications" bookmarks handlerList preopenstack openstacktempScript prevHandler openstackscriptSelection char 176 to 187script ! PAron label inputText,lableField 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 put LableField into tFieldName if there is no field tFieldName then create field tFieldName --add 1 to labelCount put inputText into field tFieldName put turtlePtTOMousePt(xycor()) into tLabelLoc set the loc of field tFieldName to Item 1 of tLabelLoc,Item 2 of tLabelLoc - 10 set the width of field tFieldName to the formattedwidth of field tFieldName set the height of field tFieldName to the formattedHeight of field tFieldName --set the tool to tTool --unLock screen end label on clearLabel labelField if there is no field labelField then create field labelField put "" into field labelField -- repeat with i = the number of fields down to 1 -- if labelField is in the name of field i then delete field i -- end repeat end clearLabel on preopencard Lock screen set the scroll of field "instructions" to 0 set the scroll of field "data" to 0 send "mouseUP" to button "drawcurves" --send "mouseUP" to button "slope1" --send "mouseUP" to button "slope3" --Lock screen end preopencard 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 put the tool into savedTool choose the oval tool set the centered to true drag from round(x0+the px of tObject ),round(y0-the py of tObject) to round(x0+the px of tObject+r),round(y0-the py of tObject-r) set the centered to false choose the savedTool 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 theObject put round(the width of this stack/2) into x0 put round(the height of this stack/2) into y0 put "graphic" &&theObject into tObject put 1 into labelCount if there is no tObject then set the style of the templateGraphic to "line" create grc word 2 of tObject end if if the style of tObject is not "line" then set the style of tObject to "line" 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 --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 function intersection p1,p2,pp1,pp2 get the paramcount if it is 1 then put item 4 of p1 into pp2 put item 3 of p1 into pp1 put item 2 of p1 into p2 put item 1 of p1 into p1 end if 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 --Check if the lines are parallel and deal with it somehow if (y2-y1)*(xp2-xp1) = (yp2-yp1)*(x2-x1) then add .0000001 to x2 if x1 = x2 or xp1 = xp2 then if x2 = x1 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 -- drawturtle 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 cleanG who put who into temp get the paramcount if it is 0 then repeat with i = 1 to the number of graphics if "grc" is in the name of grc i then set the points of grc i to "" end repeat else set the pPoints of graphic who to "" set the points of graphic who 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 cleanT who put who & "grc" into tGraphic if there is a grc tGraphic then set the points of grc tGraphic to "" end cleanT 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 millisec --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 --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 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 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 -- put tObject & 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 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 openCard global waittime --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 choose the browse tool end openCard 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 ct put "" into field "data" end ct 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 ]] |e cREVGeneral scriptChecksum .tXxS! bookmarks handlerList 9label clearLabel preopencard back bk centeredCircle commaFormat getTheObject fact startTurtle st intersection setHome home log cleanG clearLabels cleanT perpBisector clean incXY setxy truncItems setRA drawAndMOve setHeading drawTurtle seth left right rt lt forward fd pu penUp penDown pd toward direction direction2 xycor sci xcor ycor randomInRange setx sety distance heading mouseToTurtle mousePtToTurtlePt mpttp turtleToMouse tptmp turtlePtToMousePt clickPoint openCard sine cosine tangent arcsine arcTangent arcTangent2 sum pr ct functionKey tell theControls tabKeytempScript prevHandler arcsinescriptSelection char 1365 to 1364script W
on label inputText,lableField
-- 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
put LableField into tFieldName
if there is no field tFieldName then create field tFieldName
--add 1 to labelCount
put inputText into field tFieldName
put turtlePtTOMousePt(xycor()) into tLabelLoc
set the loc of field tFieldName to Item 1 of tLabelLoc,Item 2 of tLabelLoc - 10
set the width of field tFieldName to the formattedwidth of field tFieldName
set the height of field tFieldName to the formattedHeight of field tFieldName
--set the tool to tTool
--un-- Lock screen
end label
on clearLabel labelField
if there is no field labelField then create field labelField
put "" into field labelField
-- repeat with i = the number of fields down to 1
-- if labelField is in the name of field i then delete field i
-- end repeat
end clearLabel
on preopencard
-- Lock screen
set the scroll of field "instructions" to 0
set the scroll of field "data" to 0
send "mouseUP" to button "drawcurves"
--send "mouseUP" to button "slope1"
--send "mouseUP" to button "slope3"
--Lock screen
end preopencard
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
put the tool into savedTool
choose the oval tool
set the centered to true
drag from round(x0+the px of tObject ),round(y0-the py of tObject) to round(x0+the px of tObject+r),round(y0-the py of tObject-r)
set the centered to false
choose the savedTool
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 theObject
put round(the width of this stack/2) into x0
put round(the height of this stack/2) into y0
put "graphic" &&theObject into tObject
put 1 into labelCount
if there is no tObject then
set the style of the templateGraphic to "line"
create grc word 2 of tObject
end if
if the style of tObject is not "line" then set the style of tObject to "line"
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
--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
function intersection p1,p2,pp1,pp2
get the paramcount
if it is 1 then
put item 4 of p1 into pp2
put item 3 of p1 into pp1
put item 2 of p1 into p2
put item 1 of p1 into p1
end if
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
--Check if the lines are parallel and deal with it somehow
if (y2-y1)*(xp2-xp1) = (yp2-yp1)*(x2-x1) then add .0000001 to x2
if x1 = x2 or xp1 = xp2 then
if x2 = x1 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
-- drawturtle
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 cleanG who
put who into temp
get the paramcount
if it is 0 then
repeat with i = 1 to the number of graphics
if "grc" is in the name of grc i then set the points of grc i to ""
end repeat
else
set the pPoints of graphic who to ""
set the points of graphic who 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
-- un-- Lock screen
end clearLabels
on cleanT who
put who & "grc" into tGraphic
if there is a grc tGraphic then set the points of grc tGraphic to ""
end cleanT
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
-- un-- Lock 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 millisec
--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
--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 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
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
-- put tObject & 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 the formattedHeight of field nField
-- set the tool to tTool
-- un-- Lock 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 openCard
global waittime
--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
choose the browse tool
end openCard
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 ct
put "" into field "data"
end ct
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
" # $ % ' ( ) * + , - . / 0 1 3 4 5 6 7 8 9 : 8 9 S P9local angl,penDown,x,y global radPerDeg,degPerRad,noDraw,waittime,x0,y0 local x1,y1,A1,gpoints,tObject,tGraphic,labelCount on drawAndMOve set the points of graphic tGraphic to the pPoints of tObject --gPoints -- set the pPoints of tObject to gPoints set the loc of tObject to round(x0 +the px of tObject)&comma&round(y0-the py of tObject) Wait 0 millisec end drawAndMOve on back temp forward -temp end back on bk temp back temp end bk on centeredCircle r put the tool into savedTool choose the oval tool set the centered to true drag from round(x0+the px of tObject ),round(y0-the py of tObject) to round(x0+the px of tObject+r),round(y0-the py of tObject-r) set the centered to false choose the savedTool 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 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 temp 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 getTheObject(temp) into tObject put 1 into i repeat while i <= the number of fields if "fieldLabel" is in the name of field i then delete field i else add 1 to i end repeat if not exists(tObject) then answer "There is no such object." exit to top end if put 0 into labelCount put word 2 of tObject & "grc" into tGraphic replace quote with "" in tGraphic if there is no grc tGraphic then set the style of the templateGraphic to "line" create grc tGraphic 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 drawAndMove end startTurtle on st temp startTurtle temp end st 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 put (the width of this stack)/2 + xx into x0 put (the height of this stack)/2 - yy into y0 -- drawturtle 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 cleanG who put who into temp get the paramcount if it is 0 then repeat with i = 1 to the number of graphics if "grc" is in the name of grc i then set the points of grc i to "" end repeat else set the pPoints of graphic who to "" put the points of grc who to "" end if end cleanG on cleanT who put who & "grc" into tGraphic if there is a grc tGraphic then set the points of grc tGraphic to "" end cleanT 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 if the pPendown of tObject is true then put round(the px of tObject +x0)&comma&round(y0 - the py of tObject)& return after gPoints else put return & round(the px of tObject +x0)&comma&round(y0 - the py of tObject)& return after gPoints end if set the pPoints of tObject to gPoints DrawAndMove --set the lockscreen to false end setxy 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 graphic tGraphic to the pPoints of tObject --gPoints -- set the pPoints of tObject to gPoints set the loc of tObject to round(x0 +the px of tObject)&comma&round(y0-the py of tObject) Wait 0 millisec 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 -- if the pPenDown of tObject is true then -- put round(the px of tObject +x0)&comma&round(y0- the py of tObject)& return after gPoints -- else -- put return & round(x+x0)&comma&round(-y+y0)& return after gPoints -- end if -- set the points of graphic tGraphic to gPoints -- set the pPoints of tObject to gPoints -- set the loc of tObject to round(x0 +the px of tObject)&comma&round(y0-the py of tObject) --end forward 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(x+x0)&comma&round(-y+y0)& return after gPoints end if set the points of graphic tGraphic to gPoints set the pPoints of tObject to gPoints 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 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 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 repeat while angl >360 subtract 360 from angl end repeat repeat while angl < 0 add 360 to angl end repeat return angl 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 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 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 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 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 --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 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 getTheObject(who) into tObject put word 2 of tObject &"grc" into tGraphic replace quote with "" in tGraphic -- put the px of tObject into x -- put the py of tObject into y -- put the pPenDown of tObject into pendown -- put the pAngle of tObject into angl -- put the pPoints of tObject into gpoints 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 ]] |e stopMe falsepower 2 cREVGeneral scriptChecksum MޭSjYQ bookmarks handlerList drawAndMOve back bk centeredCircle commaFormat getTheObject fact startTurtle st intersection setHome home log cleanG cleanT perpBisector clean incXY setxy setRA drawAndMOve setHeading drawTurtle seth left right rt lt forward fd pu penUp penDown pd toward direction direction2 xycor sci xcor ycor randomInRange setx sety distance heading label mouseToTurtle mousePtToTurtlePt turtleToMouse turtlePtToMousePt clickPoint preopenStack sine cosine tangent arcsine arcTangent arcTangent2 sum pr functionKey tell theControls tabKeytempScript prevHandler drawAndMOvescriptSelection char 347 to 361script Molocal angl,penDown,x,y
global radPerDeg,degPerRad,noDraw,waittime,x0,y0
local x1,y1,A1,gpoints,tObject,tGraphic,labelCount
on drawAndMOve
set the points of graphic tGraphic to the pPoints of tObject --gPoints
-- set the pPoints of tObject to gPoints
set the loc of tObject to round(x0 +the px of tObject)&comma&round(y0-the py of tObject)
wait 0 millisec
end drawAndMOve
on back temp
forward -temp
end back
on bk temp
back temp
end bk
on centeredCircle r
put the tool into savedTool
choose the oval tool
set the centered to true
drag from round(x0+the px of tObject ),round(y0-the py of tObject) to round(x0+the px of tObject+r),round(y0-the py of tObject-r)
set the centered to false
choose the savedTool
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 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 temp
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 getTheObject(temp) into tObject
put 1 into i
repeat while i <= the number of fields
if "fieldLabel" is in the name of field i
then delete field i
else add 1 to i
end repeat
if not exists(tObject) then
answer "There is no such object."
exit to top
end if
put 0 into labelCount
put word 2 of tObject & "grc" into tGraphic
replace quote with "" in tGraphic
if there is no grc tGraphic then
set the style of the templateGraphic to "line"
create grc tGraphic
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
drawAndMove
end startTurtle
on st temp
startTurtle temp
end st
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
put (the width of this stack)/2 + xx into x0
put (the height of this stack)/2 - yy into y0
-- drawturtle
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 cleanG who
put who into temp
get the paramcount
if it is 0 then
repeat with i = 1 to the number of graphics
if "grc" is in the name of grc i then set the points of grc i to ""
end repeat
else
set the pPoints of graphic who to ""
put the points of grc who to ""
end if
end cleanG
on cleanT who
put who & "grc" into tGraphic
if there is a grc tGraphic then set the points of grc tGraphic to ""
end cleanT
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
if the pPendown of tObject is true
then
put round(the px of tObject +x0)&comma&round(y0 - the py of tObject)& return after gPoints
else
put return & round(the px of tObject +x0)&comma&round(y0 - the py of tObject)& return after gPoints
end if
set the pPoints of tObject to gPoints
DrawAndMove
--set the lockscreen to false
end setxy
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 graphic tGraphic to the pPoints of tObject --gPoints
-- set the pPoints of tObject to gPoints
set the loc of tObject to round(x0 +the px of tObject)&comma&round(y0-the py of tObject)
wait 0 millisec
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
-- if the pPenDown of tObject is true then
-- put round(the px of tObject +x0)&comma&round(y0- the py of tObject)& return after gPoints
-- else
-- put return & round(x+x0)&comma&round(-y+y0)& return after gPoints
-- end if
-- set the points of graphic tGraphic to gPoints
-- set the pPoints of tObject to gPoints
-- set the loc of tObject to round(x0 +the px of tObject)&comma&round(y0-the py of tObject)
--end forward
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(x+x0)&comma&round(-y+y0)& return after gPoints
end if
set the points of graphic tGraphic to gPoints
set the pPoints of tObject to gPoints
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 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
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
repeat while angl >360
subtract 360 from angl
end repeat
repeat while angl < 0
add 360 to angl
end repeat
return angl
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
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 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 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 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
--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
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 getTheObject(who) into tObject
put word 2 of tObject &"grc" into tGraphic
replace quote with "" in tGraphic
-- put the px of tObject into x
-- put the py of tObject into y
-- put the pPenDown of tObject into pendown
-- put the pAngle of tObject into angl
-- put the pPoints of tObject into gpoints
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
Z Q S X Y Mountain KB JJ black UUUUUU u E ! w v w cREVGeneral revUniqueID 1075472614741 Earth KD // ( ,, px 0py 0 pPenDown truepPoints 455,319 pAngle 0 h cREVGeneral revUniqueID 1075472614743 Canon.png @ P H + px 0py 206 pPenDown falsepPoints 446,307 446,101 pAngle 0 PNG IHDR E k gAMA OX2 tEXtSoftware Adobe ImageReadyqe<