realbasic-nug
[Top] [All Lists]

Re: Calling properties by name in a string (variable variables)

To: Realbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Re: Calling properties by name in a string (variable variables)
From: Charles Yeomans <charles@declareSub.com>
Date: Tue, 1 May 2012 14:41:34 -0400
Authentication-results: mx.google.com; spf=pass (google.com: domain of realbasic-nug-bounces@lists.realsoftware.com designates 74.124.194.228 as permitted sender) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
In-reply-to: <1543E653-3589-4746-BB3D-B1932A11D9FD@mac.com>
References: <1543E653-3589-4746-BB3D-B1932A11D9FD@mac.com>
Reply-to: Realbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
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>


<Prev in Thread] Current Thread [Next in Thread>