Hi all :)
A my friend asked me if is possible get a name of a label and change the label string with a loop. I have try this code:
rollout Test "test" width:100 height:200
(
label temp1 "hello1"
label temp2 "hello2"
on Test open do
(
for i=1 to 2 do
(
local namelabel = "temp" + i as string
namelabel.text = "changetext" + i as string
)
)
)
createDialog Test
I have always the same error : Unknown property: "text" in "temp1"
How to access the item definition (temp1/temp2) of label then update the value string ? I can do this?
Thanks for any help
By
Comments (6)
Comment policy
Very nice explanation. I really got excited for the first look with the code. I use to write the similar kind of code in frequent times.
`
hey again :)
just small thing:
You need to format it and execute it :)
It should works now,
Thanks pixamoon. I tried with the format, but without execute it! hahahahah. I see if it works!
Thanks again for support and patience
`
no prob, anytime :)
One more example
(
try(destroyDialog ::Test)catch()
rollout Test "test" width:200 height:100
(
local lblNames = #("John", "Stalone", "BruceLee", "HELLOOOO", "ZZZZzzzz", "Michael", "71")
label temp1 "hello1" width:100 height:20 style_sunkenedge:on
label temp2 "hello2" width:100 height:20 style_sunkenedge:on
button btn "Random Names" width:150
on btn pressed do for i = 1 to 2 do test.controls[i].caption = lblNames[random 1 lblNames.count]
)
createDialog Test
)
Thanks for this good example Barigazy! Thanks again :)