Pyxel,
I see a bit of confusion here. You can supply a value for Const
declarations, but not for Dim declarations; also, you cannot execute any
instructions in the global User area.
So, the following will work at any scope:
Const Questionnaire as Integer = 5
The following will fail at any scope with the error "Expression is not a
constant":
Const Questionnaire as Integer = Random(15, 45)
The following will also fail at any scope, because you cannot initialize
variables within a Dim statement:
Dim Questionnaire as Integer = 5
Instead, you need to simply declare your variable in the global User
area, then give it a value later using inline code (as explained in the
"Using E-Basic" chapter of the User's Guide). So in the global User
area, put
Dim g_Questionnaire as Integer
(I added "g_" to the name to indicate that it is a global variable),
then later in inline code give it a value, e.g.,
g_Questionnaire = Random(15, 45)
I hope that helps.
---------------
David McFarlane
E-Prime training online:
http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (
https://twitter.com/EPrimeMaster)
2016-07-07 9:47 AM, Gouraud Jonas wrote:
> Firstly, I assure you that I tried looking at the E-Prime help and previous
> posts here, but I didn't find what I wanted.
>
> That said, my problem is about the scope of a variable. Here is a
> simplified version of my experiment :
>
> Dim *Questionnaire *As Integer = Random(15, 45)
> TrialList
> Display the stimulus
> If *Questionnaire *= the number of trials then
> Ask a question
> *Questionnaire *= Random(15, 45)