Hi All,
I am a complete beginner, not just with LiveCode but with programming full stop. I've been trying to solve all my little problems myself, but may need some help with this. I'm sure there is a very simple solution.
I'm building an clinical health app, which has a number of scoring buttons which are doing identical jobs on multiple cards. All I want to do is create a "reset" button on the front screen to set the hilite of all the buttons to false.
It works as I have set out below, but is there a way of say listing all the cards on one line of script to save unwanted lines of script?
command startPressed
set the hilite of button "Importance0" on card "Goal1" to false
set the hilite of button "Importance0" on card "Goal2" to false
set the hilite of button "Importance0" on card "Goal3" to false
set the hilite of button "Importance0" on card "Goal4" to false
set the hilite of button "Importance0" on card "Goal5" to false
set the hilite of button "Importance0" on card "Goal6" to false
set the hilite of button "Importance0" on card "Goal7" to false
Any help will be much appreciated.
sending same command to multiple cards
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: sending same command to multiple cards
Hi parky0109,
1. welcome to the forum!
2. Sorry, no one-liner, but you can use a repeat loop:
Please note the brackets around the concatented card name!
This is absolutely neccessary, since the engine will first evaluate the "expression"
inside of the brackets and then use that correct card name.
Please check these great learning resources:
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
1. welcome to the forum!
2. Sorry, no one-liner, but you can use a repeat loop:
Code: Select all
...
## Seven different cards, we will create the correct card names in the loop:
repeat with i = 1 to 7
set the hilite of button "Importance0" OF cd ("Goal" & i) to false
end repeat
...This is absolutely neccessary, since the engine will first evaluate the "expression"
inside of the brackets and then use that correct card name.
Please check these great learning resources:
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
Re: sending same command to multiple cards
Great, thanks Klaus.
So I'm guessing that if I also had "Importance1" "Importance2" and "Importance3" I could add another loop say,
repeat with x = 0 to 3
and have
set the hilite of button ("Importance" & x) OF cd ("Goal" & i) to false
So I'm guessing that if I also had "Importance1" "Importance2" and "Importance3" I could add another loop say,
repeat with x = 0 to 3
and have
set the hilite of button ("Importance" & x) OF cd ("Goal" & i) to false
Re: sending same command to multiple cards
Hi parky0109,
you will of course start with 1 in your second loop
!
You will have to put this inside of the first repeat loop:
Best
Klaus
you will of course start with 1 in your second loop
You will have to put this inside of the first repeat loop:
Code: Select all
...
repeat with i = 1 to 7
repeat with x = 1 to 3
set the hilite of button ("Importance" & x) OF cd ("Goal" & i) to false
end repeat
end repeat
...Klaus
Re: sending same command to multiple cards
I used 0-3 as the first button is "Importance0"
Worked great.
Thanks for your help.
Worked great.
Thanks for your help.