On May 1, 2012, at 2:11 PM, Eduardo Gutierrez de Oliveira wrote:
> Hi.
>
> I asked this in the forum without much luck. The question might be too
> obvious or just might be impossible, but it's been nagging me for some time
> now.
>
> Imagine I have a property called "busy" and I have a string whose contents
> are "busy".
>
> How can I call the property using the string as its name?
>
> The question is intentionally vague because every time I've asked something
> like this I've been given workarounds. In reality I have already worked
> around the need several times but I've never known how to actually do this.
>
> In PHP this would be a variable variable and you'd use double dollar to call
> it up:
>
> $a = 'foo';
> $$a = 'bar';
> echo $foo; // Will output "bar"
>
> http://www.php.net/manual/en/language.variables.variable.php
>
> In Bash for:
> foo=bar
> bar=baz
>
> You'd do either of the following to get a result of "baz"
>
> echo ${!foo}
> eval echo \$$foo
>
> I don't mind if there's no way to do this at all in RealBasic, but the
> question itself has been nagging me.
>
There isn't a way to do this in REALbasic. There are perhaps ways to simulate
it, but you'll be better off writing REALbasic code in REALbasic.
Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|