placeholder in object name?

David McFarlane mcfarla9 at msu.edu
Tue Feb 15 16:13:07 UTC 2011


AW,

Not sure I quite follow the question, but I will 
throw in something.  Like Mich, my first thought 
is to use an array somehow.  Beyond that, EP does 
allow you to dynamically use any *E-Object* by 
name by use of Rte.GetObject().  Once you have 
the object you then have to "cast" it into the 
proper type before you can use the properties and methods of that object.

E.g., suppose you want to use InputBox to get the 
name of a Procedure and then run that.  You could use

Dim  procName as String
procName = InputBox$( "Enter Procedure to run:" )
CProcedure( Rte.GetObject( procName ) ).Run

Or, more succinctly if a bit more obfuscated 
(i.e., leaving out the intermediate variable),

CProcedure( Rte.GetObject( InputBox$("Enter Procedure to run:") ) ).Run

See the "Rte.GetObject" and "Casting (functions)" 
topics in the online E-Basic Help.  Note that 
this works only for E-Objects, and not for other categories of variables.

Don't know that this helps you for this case, but 
perhaps this is something that will open up doors in other projects.

Regards,
-- David McFarlane, Professional Faultfinder


At 2/15/2011 10:42 AM Tuesday, Michiel Spape wrote:
>Hiya,
>Fair question, it sometimes bugs me as well. 
>Perhaps David can provide a better answer than 
>I, but I believe, tentatively, no. That is, we 
>can't just make variables on the fly, such that
>Dim part1 as string
>part1 = "a"
>Dim part1 & "b" as string
>...Will not result in a new variable, called ab, 
>being created, but rather that an error is being 
>thrown. Sadly. A true dynamic programming 
>language should have such abilities, but not, as 
>far as I know, VB (although one might make such 
>a programming language using VB, perhaps?).
>
>That said, there is usually a way around it in 
>the form of using arrays or creating whole new 
>objects. I.e. you can not only have such simple 
>things like an array of integers, but also 
>create an indexed object, so that 
>decksoutcome(1).States(showdecks) should be 
>possible. I personally find it easier, however, 
>to start using a different language rather than 
>getting frustrated with E-prime.
>Best,
>Mich
>
>Michiel Spapé
>Research Fellow
>Perception & Action group
>University of Nottingham
>School of Psychology
>www.cognitology.eu
>
>
>-----Original Message-----
>From: e-prime at googlegroups.com 
>[mailto:e-prime at googlegroups.com] On Behalf Of liwenna
>Sent: 15 February 2011 14:38
>To: E-Prime
>Subject: placeholder in object name?
>
>Hi all,
>
>I got a question!
>
>"Long explanation
>if not interested goto *****
>
>In an experiment one of four procedures will be run in order to show
>the outcome of a chocie made by the participants (choose one of four
>decks, the outcome displays differ per choice made so the program is
>redirected to one of four procedures that hold the different outcome
>slides).
>
>On each of these outcome procedures I have an inline to redirect the
>program in case of participants clicking outside a certain button.
>This inline starts with collecting the mouse responses and in this
>line of code the name of the slideobject on which participants clicked
>has to be specified. The name of this slidedisplay obviously differs
>over the four procedures and this difference is simply the answer (a,
>b, c, d): i.e. decksoutcomeAupdatedcounters,
>decksoutcomeBupdatedcounters etc.
>
>Now.. this inline has to appear in all four procedures but the
>slideobject that is defined has to differ on this one letter... and
>although it is little effort to simply make four separate inlines (as
>I now did) I would so much like to know if it would have been possible
>to use one single inline for all four procedures in which, somehow,
>the value of the attribute "response" (or... the variable strhit for
>that matter) is placed into the objectname.
>
>*****
>I was trying to get something like this working...:
>
>dim r as string
>r$ = c.getattrib("response")
>
>         Set theState = decksoutcome&r$&updatedcounters.States(showdecks)
>
>... but to no avail.
>
>Does anyone know how to do this? I'd like to learn for future use :)
>
>Thanks in advance,
>
>AW

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.



More information about the Eprime mailing list