home *** CD-ROM | disk | FTP | other *** search
- on MaxTrace
- return 5
- end
-
- on puppetSockets
- set start to FirstSocketSprite()
- set finish to start + MaxTrace() - 1
- repeat with i = start to finish
- puppetSprite(i, 1)
- end repeat
- end
-
- on MarkPlugAsFree thePlug
- global FreePlugsList
- setAt(FreePlugsList, thePlug, 1)
- end
-
- on MarkPlugAsUsed thePlug
- global FreePlugsList
- setAt(FreePlugsList, thePlug, 0)
- end
-
- on ResetPlugs
- global FreePlugsList
- set FreePlugsList to []
- repeat with i = 1 to MaxTrace() + 1
- append(FreePlugsList, 1)
- end repeat
- end
-
- on FirstFreePlug
- global FreePlugsList
- set p to 1
- repeat with flag in FreePlugsList
- if flag then
- exit repeat
- end if
- set p to p + 1
- end repeat
- return p
- end
-
- on SetPlugText thePlug, theText
- set theCast to CastFromPlug(thePlug)
- set the text of cast theCast to theText
- end
-
- on MakeNewPlug theText
- set myPlug to FirstFreePlug()
- SetPlugText(myPlug, theText)
- MarkPlugAsUsed(myPlug)
- return myPlug
- end
-
- on FirstSocketSprite
- return 34
- end
-
- on FirstPlugCast
- return 1991
- end
-
- on SpriteFromSocket theSocket
- return FirstSocketSprite() + theSocket - 1
- end
-
- on CastFromPlug thePlug
- return thePlug + FirstPlugCast() - 1
- end
-
- on PlugFromCast theCast
- return theCast - FirstPlugCast() + 1
- end
-
- on LatestSprite
- global TraceLen
- return FirstSocketSprite() + TraceLen - 1
- end
-
- on HideSocket theSocket
- set theSprite to SpriteFromSocket(theSocket)
- set the blend of sprite theSprite to 0
- end
-
- on ShowSocket theSocket
- set theSprite to SpriteFromSocket(theSocket)
- if theSprite = LatestSprite() then
- repeat with i = FirstSocketSprite() to FirstSocketSprite() + MaxTrace() - 1
- if i = LatestSprite() then
- set the blend of sprite theSprite to 100
- next repeat
- end if
- if the blend of sprite i = 100 then
- set the blend of sprite i to 66
- end if
- end repeat
- else
- set the blend of sprite theSprite to 66
- end if
- end
-
- on PlugIn theSocket, thePlug
- set theSprite to SpriteFromSocket(theSocket)
- set theCast to CastFromPlug(thePlug)
- set the castNum of sprite theSprite to theCast
- end
-
- on UnplugAtSocket theSocket
- set theSprite to SpriteFromSocket(theSocket)
- set theCast to the castNum of sprite theSprite
- set thePlug to PlugFromCast(theCast)
- return thePlug
- end
-
- on InitTraceDisplay
- ResetPlugs()
- repeat with i = 1 to MaxTrace()
- HideSocket(i)
- end repeat
- end
-
- on DeleteFromTraceDisplay
- global TraceLen
- set plug to UnplugAtSocket(TraceLen)
- MarkPlugAsFree(plug)
- HideSocket(TraceLen)
- end
-
- on ShuffleUpTraceDisplay
- global TraceLen
- set plug to UnplugAtSocket(1)
- MarkPlugAsFree(plug)
- if TraceLen > 1 then
- repeat with i = 1 to TraceLen - 1
- set plug to UnplugAtSocket(i + 1)
- PlugIn(i, plug)
- end repeat
- end if
- HideSocket(TraceLen)
- end
-
- on AddTrace ArticleRef, ArticleTitle
- global theTrace, TraceLen
- set theRecord to [ArticleRef, ArticleTitle]
- append(theTrace, theRecord)
- set TraceLen to TraceLen + 1
- end
-
- on RemoveTrace thePos
- global theTrace, TraceLen
- deleteAt(theTrace, thePos)
- set TraceLen to TraceLen - 1
- end
-
- on RemoveFirstTrace
- RemoveTrace(1)
- end
-
- on RemoveLastTrace
- global TraceLen
- RemoveTrace(TraceLen)
- end
-
- on ShuffleUpTrace
- RemoveFirstTrace()
- end
-
- on GetTrace entryNo
- global theTrace
- set theEntry to getAt(theTrace, entryNo)
- return theEntry
- end
-
- on GetRefPart theEntry
- set theRef to getAt(theEntry, 1)
- return theRef
- end
-
- on GetRef entryNo
- set theEntry to GetTrace(entryNo)
- set theRef to GetRefPart(theEntry)
- return theRef
- end
-
- on GetLastRef
- global TraceLen
- return GetRef(TraceLen)
- end
-
- on InitTrace
- global theTrace, TraceLen
- set theTrace to []
- set TraceLen to 0
- end
-
- on StepOn ArticleRef, ArticleName
- global TraceLen, theTrace
- set myPlug to MakeNewPlug(ArticleRef)
- if TraceLen = MaxTrace() then
- ShuffleUpTraceDisplay()
- ShuffleUpTrace()
- end if
- AddTrace(ArticleRef, ArticleName)
- PlugIn(TraceLen, myPlug)
- ShowSocket(TraceLen)
- end
-
- on StepBack
- global TraceLen
- if TraceLen = 0 then
- set returnRef to "none"
- else
- DeleteFromTraceDisplay()
- set returnRef to GetLastRef()
- end if
- return returnRef
- end
-
- on GoBackTo n
- global TraceLen
- set returnRef to GetRef(n)
- repeat with i = TraceLen down to n + 1
- DeleteFromTraceDisplay()
- RemoveTrace(i)
- end repeat
- ShowSocket(TraceLen)
- return returnRef
- end
-