Re: Help
> Hello,
>
> How to change a sequence to name of control.
>
> for example...
>
> I've a sequence "button1, button2, button3" and I want put som text in
> control with the same name as a part of sequence..
>
> setText(button1, "Test")
>
> Bye Vlado
This can not be done directly, but there are ways to do this:
---------- START CODE
constant
button1 = create(PushButton, ...),
button2 = create(PushButton, ...),
button3 = create(PushButton, ...),
...
constant lookup_table = {
{"button1", button1},
{"button2", button2},
{"button3", button3},
...
}
function getControlFromString(sequence string)
for i = 1 to length(lookup_table) do
if equal(lookup_table[i][1], string) then
return lookup_table[i][2]
end if
end for
return 0 -- no control found
end function
integer ctl
ctl = getControlFromString("button1")
if ctl != 0 then
setText(ctl, "Test")
end if
---------- END CODE
If there are a lot of controls, you could speed it up by using a
hash-table instead of a simple lookup-table. Or make sure the lookup-table
is sorted alphabetically, and use an optimized search algorithm.
If you want to split the string "button1, button2, button3" into
{"button1", "button2", "button3"}, you could use Kat's Strtok
(http://www.tiggrbox.info/program/Euphoria.html).
--
Tommy Carlier
tommy online: http://users.pandora.be/tommycarlier
|
Not Categorized, Please Help
|
|