Slide duration defined by variable, not attribute

David McFarlane mcfarla9 at msu.edu
Fri Jul 8 14:03:52 UTC 2011


Tobias,

Hmm, well, from this distance I cannot tell what you are doing wrong, 
I just put the code anywhere before the object and it works perfectly 
for me (I tried just now and made absolutely sure).  (I did have to 
make sure to type in the correct number -- I first mistakenly typed 
"5" for 5 s, forgetting that I had to enter 5000 for 5000 ms, once I 
did that it was OK.  So do make sure you have entered the correct 
values.)  More importantly, on the object itself I just left the 
Duration at its default of 1000.  The exact value does not matter at 
all, but you must, *must* use a literal value in the Duration 
property of the object itself, do *not* use an attribute 
reference!!  If you use an attribute reference for the duration then 
that attribute value will replace the value from your earlier code -- 
you could see this for yourself simply by looking at the source code 
that E-Studio generates, you don't need my help to figure this out.

Of course, putting a literal value in for the Duration of the object 
will deceive users into thinking that the Duration for that object is 
that literal value, instead of the value that comes from your inline 
code, which is the point of my first objection below.  And if you can 
get this to work by setting an attribute reference in code, then why 
bother getting it to work withouth the attribute reference, except as 
a mere academic exercise (of which I would approve)?

-- David McFarlane, Professional Faultfinder


At 7/8/2011 07:23 AM Friday, you wrote:
>Thanks for your sage advice. I think I just found it annoying to
>always use "c.setattrib" etc., never really knowing by heart the exact
>syntax. Also, I sometimes had error mesagges because the variable
>types didn't match etc. I'll think about it, but for the moment: THis
>snip of code you were writing, at what point in the procedure should I
>include it? I was actually aware that "StimText.Duration = durationA"
>should work, but if I put at a point before the object, the value
>entered in the object will overwrite it. And after the object, it's
>already too late :-p
>
>Best,
>Tobias
>
>On 7 Jul., 19:56, David McFarlane <mcfar... at msu.edu> wrote:
> > 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