Problem getting If statement to work properly


Author
Message
DCole9
DCole9
Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)
Group: Forum Members
Posts: 42, Visits: 220
D'oh!  That was it!  I had never needed to specify the element type before when specifying stimulus frames.  I guess if you do insert or set stimulus frames then you need to but for the /stimulusframes tag you do not.

Thanks so much!
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
What are those errors specifically?

Note that the syntax in the functions is partly incorrect: Suppose you want to set a <text> stimulus called mytext. Then that's

setstimulusframe(text.mytext, 1)

not

setstimulusframe(mytext, 1)

Edited 10 Years Ago by Dave
DCole9
DCole9
Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)
Group: Forum Members
Posts: 42, Visits: 220
Thanks for the tip with the expressions Dave that helped.  I'm receiving some errors with inserting the stimulus frames even though the if statements are returning true.  Is there something wrong with the syntax?

"/ontrialbegin = [if ((values.randomposition == "1") && (values.response == "patch1") && (values.randomdemand == "lowpatch1"))
{trial.patchtrial.setstimulusframe(focus, 1); trial.patchtrial.insertstimulusframe(choose, 1); trial.patchtrial.insertstimulusframe(lownumber, 1); trial.patchtrial.insertstimulusframe(blankpatch1, 1); trial.patchtrial.insertstimulusframe(patch2, 1)}]"



Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
If you want to check if or if not any of your conditions evaluates to true, you can add

<expressions>
/c1 = ((values.randomposition == 1) && (values.response == "patch1") && (values.randomdemand == "lowpatch1" ))
/c2 = ((values.randomposition == 1) && (values.response == "patch2") && (values.randomdemand == "highpatch1" ))
/c3 = ((values.randomposition == 2) && (values.response == "patch1") && (values.randomdemand == "lowpatch1" ))
/c4 = ((values.randomposition == 2) && (values.response == "patch2") && (values.randomdemand == "highpatch1" ))
</expressions>

to the script and log those expressions to the data file. You will find that you not all that can conditions are covered by your conditions. This is for example the case with

((values.randomposition == 1) && (values.response == "patch1") && (values.randomdemand == "highpatch1"))

A statement such as

/ontrialbegin = [if ((values.randomposition == 1) && (values.response == patch1) && (values.randomdemand == "lowpatch1"))

will fail to evaluate to true due to missing double-quotes.

DCole9
DCole9
Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)Distinguished Member (4.4K reputation)
Group: Forum Members
Posts: 42, Visits: 220
I'm having a problem getting the following if statement to change a value correctly.  I want to check the random position variable, the last trial's response, and the random demand variable to assign the location of the next stimulus.   All of the if statement conditions look correct in the log file but yet it does not pass as "true" and set the values accordingly.  
"/ontrialbegin = [if ((values.randomposition == 1) && (values.response == "patch1") && (values.randomdemand == "lowpatch1" )) {values.lownumbery = 40%; values.highnumbery = 60%}]"


Additionally I'm having  similar problem but using an if statement to insert stimulus frames.  An example is-
/ontrialbegin = [if ((values.randomposition == 1) && (values.response == patch2) && (values.randomdemand == "lowpatch1"))
{trial.patchtrial.setstimulusframe(focus, 1); trial.patchtrial.insertstimulusframe(choose, 1); trial.patchtrial.insertstimulusframe(highnumber, 1); trial.patchtrial.insertstimulusframe(blankpatch2, 1); trial.patchtrial.insertstimulusframe(patch1, 1); }]"

Attachments
DemandSelection.iqx (241 views, 31.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search