multiple wait command

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

gilar
Posts: 96
Joined: Sat Sep 26, 2015 12:59 pm

Re: multiple wait command

Post by gilar » Mon Mar 21, 2016 4:19 am

Hi jacque .... thanks for the code, this give me another option.

Code: Select all

You should step through each line of the code in the debugger to see what it does. If you don't know how to do that, ask us.
Could you please explain for me ... ?

I Try your code and This what I've got:

Code: Select all

button "abtn1": execution error at line 5 (Chunk: no such object), char 8
Actually I don't Understand from this part.

Code: Select all

repeat with x = 1 to 10
    put "M" & x into tBtnName  -- create the button name
    if the backgroundcolor of btn tBtnName = "128,0,0" then
      put tBtnName & comma after tBtnList
    end if
Why we have to put "M"?
-- make a list of all active buttons: ===> Do I have to create code?

Sorry for my Newbie Question.

Thank You Very Much.
Gilar | from INDONESIA

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: multiple wait command

Post by jacque » Tue Mar 22, 2016 4:45 am

gilar wrote:

Code: Select all

You should step through each line of the code in the debugger to see what it does. If you don't know how to do that, ask us.
Could you please explain for me ... ?
That's a long explanation. The User Guide has a section on how to use the debugger, with a good reference picture on page 327 (or search for "debugger" in the guide.) The short explanation is that you place a red dot (a breakpoint) at the left of a script line near the beginning of the handler, and when you run the script it will stop at the breakpoint. The guide has an picture of a red dot breakpoint, click at that location to set it. Then you can go slowly through the handler, one line at a time, by clicking the Step Over icon at the top left of the script editor and watch the variables at the bottom of the window. You can see their values change after each line of script. It is the most valuable tool we have for debugging and for seeing how the script works.

If you step through the handler I posted you will see all the button names created as the repeat loop runs. It should help you understand how the script works.
I Try your code and This what I've got:

Code: Select all

button "abtn1": execution error at line 5 (Chunk: no such object), char 8
Actually I don't Understand from this part.

Code: Select all

repeat with x = 1 to 10
    put "M" & x into tBtnName  -- create the button name
    if the backgroundcolor of btn tBtnName = "128,0,0" then
      put tBtnName & comma after tBtnList
    end if
Why we have to put "M"?
-- make a list of all active buttons: ===> Do I have to create code?
You don't have to create code for the commented line; it is an explanation of the repeat loop that follows. The repeat loop makes a list of the buttons that are currently red.

In your screen shot, all the red buttons are named "M1", "M2", etc. I assumed that was their actual names. To make a button name, I use "M" plus the number represented by "x" in the repeat loop. So the first time through the loop, x=1, and by adding "M" to the front the button name is "M1". The next time through the loop, x=2 and the button name is "M2". That continues until we have a list of the red buttons: M1,M2,M5,M6, for example.

If your buttons are named "abtn" instead of "M" then you should change the "M" in the script to "abtn". When you do that, you will get a list like this: abtn1,abtn3,abtn8, etc.

The second repeat loop does a similar thing, but it gets the number from the button name in the list. It puts "mbtn" before the number so it gets a name like "mbtn1". It does the same for the "delayAP" field name and the "delayAR" field name so it can get the delay seconds for each. Then it sends a mouseUp command to the mbtn for the start delay and another mouseUp for the release delay.

The result is a list of pending messages that LC will execute at their designated times. You can view the pending messages in the message box "pending messages" pane.

This method is a little advanced for a beginner but I think it is a good way to do the job.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply