Page 1 of 1

How to use star in the name of a container

Posted: Thu Apr 01, 2010 5:42 pm
by fmuller
Hello,

I search a solution for have all button on a card updated in a loop, example below :
In fact I have many button all names started with "btn_U" after I use a number and after I use something.
The goal with the loop is to update every button in a shoot using the * (star)

repeat with tVarCount = 1 to 4
set label of button "btn_U" & tVarCount & "*" to 0
end repeat

My script doesn't work, if you have an idea it could be great.
Thanks Fabrice

Re: How to use star in the name of a container

Posted: Thu Apr 01, 2010 6:19 pm
by sturgis
Change it thusly:

Code: Select all

   repeat with i = 1 to 4
      set the label of button ("btn_U" & i & "*") to 0
   end repeat
This forces evaluation of the "btn_U & i & "*"" FIRST so that the engine just sees button "btn_U1*". If the parens aren't there, the engine expects "to" after "btn_U".

edit: Change the i back to your variable name of course.

Re: How to use star in the name of a container

Posted: Thu Apr 01, 2010 6:29 pm
by Klaus
Grüezi Fabrice,

let me first see if I understand what you are after :)

You have for example 4 buttons on your card named:
btn_U1_something_else
btn_U2_a_different_thing
btn_U3_swiss_cheese
btn_U4_chaes_fondue
?

And you want to set their label to the number 0 in a repeat loop without writing their names?
Or dou you mean to set their label to empty?

Whatever, this will not work with "wildcards" like "*"
A "repeat loop" demands correct names!

BUT you could do something like this:

Code: Select all

...
lock screen

## Now cycle through all buttons on the current card and check their names
repeat with i = 1 to the num of btns of this cd
   if the short name of btn i begins with "btn_U" then
      set the label of btn i to empty ## or "0"
   end if
end repeat
unlock screen
...
Not tested, but should work (Famous last words :lol: )
Hope this helps.


Best from germany

Klaus

Re: How to use star in the name of a container

Posted: Thu Apr 01, 2010 6:47 pm
by fmuller
sturgis wrote:Change it thusly:

Code: Select all

   repeat with i = 1 to 4
      set the label of button ("btn_U" & i & "*") to 0
   end repeat
This forces evaluation of the "btn_U & i & "*"" FIRST so that the engine just sees button "btn_U1*". If the parens aren't there, the engine expects "to" after "btn_U".

edit: Change the i back to your variable name of course.
Hello,

Thanks for reply. I tried but it doesn't work, error message during execution :
execution error at line 6 (Chunk: no such object) near "btn_U1*", char 17

Fabrice

Re: How to use star in the name of a container

Posted: Thu Apr 01, 2010 7:06 pm
by sturgis
My apologies, misunderstood what you were asking. Go with Klaus and you should be set.

Re: How to use star in the name of a container

Posted: Thu Apr 01, 2010 8:00 pm
by fmuller
Klaus wrote:Grüezi Fabrice,

let me first see if I understand what you are after :)

You have for example 4 buttons on your card named:
btn_U1_something_else
btn_U2_a_different_thing
btn_U3_swiss_cheese
btn_U4_chaes_fondue
?

And you want to set their label to the number 0 in a repeat loop without writing their names?
Or dou you mean to set their label to empty?

Whatever, this will not work with "wildcards" like "*"
A "repeat loop" demands correct names!

BUT you could do something like this:

Code: Select all

...
lock screen

## Now cycle through all buttons on the current card and check their names
repeat with i = 1 to the num of btns of this cd
   if the short name of btn i begins with "btn_U" then
      set the label of btn i to empty ## or "0"
   end if
end repeat
unlock screen
...
Not tested, but should work (Famous last words :lol: )
Hope this helps.


Best from germany

Klaus
Hi Klaus,

Thanks, you understand well. it works perfectly with cheese and chocolate :D

Cheers from Switzerland.
Fabrice

Re: How to use star in the name of a container

Posted: Thu Apr 01, 2010 8:02 pm
by fmuller
sturgis wrote:My apologies, misunderstood what you were asking. Go with Klaus and you should be set.
No Problem, I was not so clear, but usage of () is interesting also for some other application :D

Thanks for taking time.

Cheers, Fabrice