problem with a summation object
David McFarlane
mcfarla9 at msu.edu
Thu Mar 1 17:00:59 UTC 2012
Mich,
Indeed, that is exactly correct, and I am quite chagrined that I
overlooked that coding mistake myself in Max's original post. I
guess it just goes to show...
This behavior, of course, comes from Microsoft Visual Basic for
Applications (VBA), from which E-Basic is derived. *Each* variable
must be *explicitly* typed, else by default it is type Variant, as
you said. In VBA/E-Basic you could accomplish the same effect on a
single line as follows:
Dim SummationAcc as Summation, SummationRT as Summation
Programmers experienced in other languages such as C/C++ will find
this particularly confusing, as the equivalent statement in C/C++
would read simply
Summation SummationAcc, SummationRT;
which would reasonably enough declare both SummationAcc & SummationRT
as type Summation in one simple easy-to-read line. But this is
VBA/E-Basic, not C/C++
Of course it is easy to overlook a lack of explicit type declarations
on single lines like that, hence many VBA/E-Basic style guides
recommend using a separate line for each variable declaration, as you
illustrated. It seems to me that I have run across this documented
somewhere in the E-Prime materials, but I don't recall offhand
whether this behavior is explained in Chapter 4 of the User's Guide,
and I am too lazy to look it up right now.
---
David McFarlane
E-Prime training
online: http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (twitter.com/EPrimeMaster)
At 3/1/2012 10:55 AM Thursday, Michiel Sovijarvi-Spape wrote:
>Hi,
>Correct me if I'm wrong, anyone knowing better and actually having E-Prime
>on their desktop (anyone here at Aalto or Helsinki Uni anyway?), but, as far
>as I remember:
>"Dim SummationAcc, SummationRT as Summation" is interpreted as
>Dim SummationAcc as Variant
>Dim SummationRT as Summation
>...variant being that weird basic type which changes from integer to string
>to double on the basis of its value. A summation object, however, is not a
>type but a separate class.
>I agree with you that it would be more convenient if e-prime would either
>accept various type declarations in one line (double A, B, C etc all being
>doubles), or actually give a warning. Although you might say this is just
>being punishing for lazy coding, I have met academics enough who had this
>problem. It reminds me somewhat of this fascinating thing in flash
>actionscript, where
>IF x = 3 THEN ....
>is interpreted as "if it's fine to store the value of 3 in the variable x
>then continue", so that you get no error message, but your code will start
>exhibiting very strange behaviour (since if x = 3, it will continue, but
>also if x happens to be 4, x = 3 still is evaluated as "true": the laziness
>here was with me and doing too much basic, for not seeing the proper code IF
>x == 3 THEN)
>
>Anyway.
>Best,
>Mich
>
>-----Original Message-----
>From: e-prime at googlegroups.com [mailto:e-prime at googlegroups.com] On Behalf
>Of Maria
>Sent: 01 March 2012 17:28
>To: E-Prime
>Subject: Re: problem with a summation object
>
>Hallo David,
>
>the error occurued in the line where the observation should be added.
>I deleted this thread because I found the mistake:
>
>When you define the summation objects you have to write them into
>seperate lines like:
>
>Dim SummationAcc as Summation
>Dim SummationRT as Summation
>
>and not like:
>
>Dim SummationAcc, SummationRT as Summation
>
>I do not have an explanation for this...
>
>
>
>
>On 28 Feb., 17:49, David McFarlane <mcfar... at msu.edu> wrote:
> > Max,
> >
> > Hmm, another question that could go to PST Web Support
>athttp://support.pstnet.com/e%2Dprime/support/login.asp. Anyway, what
> > was the exact line of code that produced the error? Typically, an
> > "Object does not have a default value" error occurs when you use an
> > object but fail to specify which *property* of the object you
> > mean. You can get away with that only when the object does have a
> > default property, otherwise you must explicitly specify which
> > property you mean.
> >
> > To take a contrived example, the following will create such an error:
> >
> > SummationRTA.AddObservation CInt(ReactionInterval)
> >
> > whereas the following will not:
> >
> > SummationRTA.AddObservation CInt(ReactionInterval.RT)
> >
> > -- David McFarlane
> >
> > At 2/2/2012 06:02 AM Thursday, you wrote:
> >
> > >Dear everyone,
> >
> > >I tried to use a summation object to give feedback to experimental
> > >subjects about their accuracy and reaction times.
> > >I used following code:
> > >Dim SummationAccA, SummationAccB, SummationRTA, SummationRTB as
> > >Summation
> > >(global variables)
> >
> > >Set SummationAccA = New Summation
> > >Set SummationRTA = New Summation
> > >Set SummationAccB = New Summation
> > >Set SummationRTB = New Summation
> > >(before running the list)
> >
> > >SummationAccA.AddObservation ReactionInterval.ACC
> > >SummationRTA.AddObservation ReactionInterval.RT
> > >SummationAccB.AddObservation ReactionInterval2.ACC
> > >SummationRTB.AddObservation ReactionInterval2.RT
> > >(ReactionInterval & Reactioninterval2 are slide objects)
> >
> > >By attempting to add the accuracies and reaction times following error
> > >occurs:
> > >"Object does not have a default value"
> >
> > >I used the same principle in further experiments and there it worked.
> > >I hope there is just a simple mistake, thanks for answers,
> > >best regards,
> > >Max
--
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