Start, Stop, Continue

Ken Ray kray at sonsothunder.com
Fri Sep 9 11:27:04 EDT 2005


On 9/9/05 7:10 AM, "Glen Bojsza" <gbojsza at gmail.com> wrote:

> The Start button on a mouseUp starts to cycle through a list of commands
> that move graphics, shows and hides fields etc.
> 
> The Stop button on mouseUp stops the cycle of commands the Start button
> launched, hides itself and shows a Continue button.
> 
> The Continue button on mouseUp starts the cycle of commands the Start button
> initially launched but from where the cylce had been stopped.
> 
> This is my foray into multimedia and interaction with Rev so I hope the list
> will bear with me... traditionally I have worked on "static" apps.
> 
> Any suggestions or reference stacks would be appreciated.

My suggestion would be to work with a list of commands in a custom property,
and then use "send" to "do" each line, one at a time, recursively "sending"
to the same handler. Manage a custom property "pointer" that indicates what
command line is being executed. The Stop button would cancel the pending
message, and the Continue button would execute the next command after the
"pointer". Something like this (assumes "uCommands" property contains the
list of commands to execute, "uPointer" property holds the indicator for
which line is being executed):


-- Start button
on mouseUp
  set the uPointer of this card to 0
  DoNextCommand
end mouseUp

-- Stop button
on mouseUp
  CancelPending "DoNextCommand"
end mouseUp

-- Continue button
on mouseUp
  DoNextCommand
end mouseUp

-- card script?
on DoNextCommand
  put the uCommands of this card into tCmdList
  put the uPointer of this card into tLine
  add 1 to tLine
  put line tLine of tCmdList into tCmd
  if tCmd = "" then
    exit DoNextCommand  -- already executed last cmd in list
  else
    do (line tLine of tCmdList)
    DoNextCommand
  end if
end DoNextCommand

on CancelPending pMsg
  put the pendingMessages into tPending
  if (pMsg <> "") and (pMsg <> "all") then
    filter tPending with "*," & pMsg & ",*"
  end if
  repeat for each line tMsg in tPending
    cancel item 1 of tMsg
  end repeat
end CancelPending

 HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list