Slide duration defined by variable, not attribute

David McFarlane mcfarla9 at msu.edu
Thu Jul 7 17:56:09 UTC 2011


Tobias,

First, I disagree with your premise about attribute references being 
"more complicated and not really straight forward" than 
variables.  It is just as simple and straightforward to use attribute 
references in code as it is to use variables in code, and in most 
cases attribute references offer distince advantages.  I started out 
using variables just as you describe (and so will get around to 
actually answering your question :)), but once I understood attribute 
references better I switched to using those whenever I can, for the 
following reasons:

- Using a variable for, say, Duration, leaves *no* clue in the 
program design that that value will vary -- to the contrary, the 
object's Duration will show as a constant, so programmers just have 
to "know" that this value will vary in some code somewhere.  By 
contrast, an attribute reference in the object serves notice that 
that value varies, and thus is much "friendlier" to programmers.

- Using a variable does *not* log the varying value, so after the 
experiment you have no record of what really happened.  Using an 
attribute reference fixes this at no extra cost.  Yes, you could 
throw in a c.SetAttrib "DurationA", durationA just to log the, but 
once you go to that length you might as well just use the attribute 
in your object, no?

So except for extreme cases, if I need to vary a property value from 
code instead of a List, I always do something like

c.SetAttrib "DurationA", durationA

and then use [DurationA] for the Duration property of my stimulus object.

But let's suppose that you really have a valid purpose for this (or 
wish to simply ignore my sage advice).  Here's how you do 
that.  Suppose you want to set the Duration property of a stimlus 
object called StimText to a variable called durationA.  In code, you simply do

StimText.Duration = durationA

That's it!  Absurdly simple.  You can do this for a whole host of 
object properties, just look at the E-Basic Help page for any desired 
object.  For that matter, work through Chapter 4 of the User's Guide 
that came with E-Prime, and take a course in Introduction to Computer 
Programming.

Regards,
-- David McFarlane, Professional Faultfinder


At 7/7/2011 01:23 PM Thursday, you wrote:
>Hi,
>
>I would like to define the duration of an object (slide in this case)
>in E-Prime with a variable. As far as I know, instead of specifying
>the duration directly by a number, you can also use square brackets
>and enter, let's say [durationA]. This refers to the attribute in the
>current list named "durationA". However, using attributes is much more
>complicated and not really straight forward. Is there a way of using
>variables instead?
>
>Thanks a lot in advance!
>Tobias

-- 
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