﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Millisecond Forums » Millisecond Forums » Inquisit 4  » If statements within trial's /stimulusframes?</title><generator>InstantForum 2017-1 Final</generator><description>Millisecond Forums</description><link>https://forums.millisecond.com/</link><webMaster>Millisecond Forums</webMaster><lastBuildDate>Wed, 16 Sep 2026 10:39:55 GMT</lastBuildDate><ttl>20</ttl><item><title>If statements within trial's /stimulusframes?</title><link>https://forums.millisecond.com/Topic14788.aspx</link><description>Hi Inquisiters,&lt;br/&gt;I'm running into a problem with a task-switching paradigm in which subjects have a choice between 2 colored patches. &amp;nbsp;The patches are randomly assigned a high demand and a low demand condition which effects the display color of a number. &amp;nbsp;The color of the number will effect whether they make an "even or odd" decision or a "&amp;gt; 5 or &amp;lt; 5" decision.&lt;br/&gt;&lt;br/&gt;What I'm trying to do is setup my stimulus frames to display from the high demand number list when the certain criteria are true (random position variable = 1, they selected patch1, etc).&lt;br/&gt;&lt;br/&gt;My question is: &amp;nbsp; Do I need to set up individual trials for each possibility? &amp;nbsp;(e.g. trialA for random position 1, select.patch1. &amp;nbsp;trialB for random position 2, select.patch1. etc. etc.)&lt;br/&gt;&lt;br/&gt;Or is it possible to use something like &lt;br/&gt;&lt;strong&gt;"/ontrialbegin = [if((values.XX == 1( &amp;amp;&amp;amp; (values.YY == 2 )) values.stimframes = "displaytext, displaynum, patch1, patch2]&lt;br/&gt;/stimulusframes = values.stimframes"&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;or &lt;strong&gt;"/stimulusframes = [if ((values.XX == 1) &amp;amp;&amp;amp; (values.YY == 2)) 1 = displaytext, displaynum, patch1, patch2]" &lt;/strong&gt;?&amp;nbsp;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Thank you for your help!</description><pubDate>Fri, 31 Oct 2014 10:26:53 GMT</pubDate><dc:creator>DCole9</dc:creator></item><item><title>RE: If statements within trial's /stimulusframes?</title><link>https://forums.millisecond.com/Topic14799.aspx</link><description>No, you do not. You need to use curly braces to bundle all the statements to be executed under the if-condition;&lt;br/&gt;&lt;br/&gt;/ ontrialbegin = [if (true) { do stuff; do more stuff; do even more stuff; }]&lt;br/&gt;&lt;br/&gt;Also, it's not clear to me why you use setstimulusframe() in both statements. You would only use it in the 1st and then insertstimulusframe() in all subsequent ones:&lt;br/&gt;&lt;br/&gt;&amp;lt;list fixationduration&amp;gt;&lt;br/&gt;/ items = (500, 5000, 10000)&lt;br/&gt;&amp;lt;/list&amp;gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;trial mytrial&amp;gt;&lt;br/&gt;/ ontrialbegin = [if (true) {trial.mytrial.setstimulustime(text.a, list.fixationduration.nextvalue);&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; trial.mytrial.insertstimulustime(text.b, list.fixationduration.nextvalue); }]&lt;br/&gt;/ ontrialend = [trial.mytrial.resetstimulusframes()]&lt;br/&gt;/ stimulustimes = [0=fixation]&lt;br/&gt;/ validresponse = (57)&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text fixation&amp;gt;&lt;br/&gt;/ items = ("+")&lt;br/&gt;&amp;lt;/text&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text a&amp;gt;&lt;br/&gt;/ items = ("A")&lt;br/&gt;/ position = (45%, 50%)&lt;br/&gt;&amp;lt;/text&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text b&amp;gt;&lt;br/&gt;/ items = ("B")&lt;br/&gt;/ position = (55%, 50%)&lt;br/&gt;&amp;lt;/text&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;block myblock&amp;gt;&lt;br/&gt;/ trials = [1-3=mytrial]&lt;br/&gt;&amp;lt;/block&amp;gt;&lt;br/&gt;</description><pubDate>Fri, 31 Oct 2014 10:26:53 GMT</pubDate><dc:creator>Dave</dc:creator></item><item><title>RE: If statements within trial's /stimulusframes?</title><link>https://forums.millisecond.com/Topic14798.aspx</link><description>Ah got it. &amp;nbsp;It's working now. &amp;nbsp;&lt;br/&gt;&lt;br/&gt;For your previous post I need to declare each stimulus frame as a separate line correct? &amp;nbsp;When I separated them by semi-colons it didn't work.&lt;br/&gt;&lt;br/&gt;For example)&lt;br/&gt;&lt;strong&gt;"/ontrialbegin = [if ((values.randomposition == 1) &amp;amp;&amp;amp; (trial.InitialSelect.response == "patch1") &amp;amp;&amp;amp; (values.randomdemand == "lowpatch1")) trial.patchtrial.setstimulusframe(focus, 1);]&lt;br/&gt;/ontrialbegin = [if ((values.randomposition == 1) &amp;amp;&amp;amp; (trial.InitialSelect.response == "patch1") &amp;amp;&amp;amp; (values.randomdemand == "lowpatch1")) trial.patchtrial.setstimulusframe(choose, 1);]"&lt;br/&gt;&lt;/strong&gt;&lt;br/&gt;</description><pubDate>Fri, 31 Oct 2014 10:15:48 GMT</pubDate><dc:creator>DCole9</dc:creator></item><item><title>RE: If statements within trial's /stimulusframes?</title><link>https://forums.millisecond.com/Topic14796.aspx</link><description>This won't work / is invalid syntax:&lt;br/&gt;&lt;br/&gt;&amp;lt;text highnumber&amp;gt;&lt;br/&gt;/items = ("")&lt;br/&gt;/position = (50%, values.numbery)&lt;br/&gt;/fontstyle = ("Arial", values.focussize, true, false, false, false, 5, 0)&lt;br/&gt;&lt;strong&gt;/txcolor = (values.highnumcolor)&lt;/strong&gt;&lt;br/&gt;/txbgcolor = (white)&lt;br/&gt;/select = values.numberget&lt;br/&gt;&amp;lt;/text&amp;gt;&lt;br/&gt;&lt;br/&gt;The way to do this is defining&lt;br/&gt;&lt;br/&gt;&amp;lt;text highnumber&amp;gt;&lt;br/&gt;/items = ("")&lt;br/&gt;/position = (50%, values.numbery)&lt;br/&gt;/fontstyle = ("Arial", values.focussize, true, false, false, false, 5, 0)&lt;br/&gt;/txbgcolor = (white)&lt;br/&gt;/select = values.numberget&lt;br/&gt;&amp;lt;/text&amp;gt;&lt;br/&gt;&lt;br/&gt;and then doing&lt;br/&gt;&lt;br/&gt;/ ontrialbegin = [text.highnumber.textcolor=values.highnumcolor]&lt;br/&gt;&lt;br/&gt;Also, you need to get rid of the double-quotes in&lt;br/&gt;&lt;br/&gt;&amp;lt;list highdemandcolor&amp;gt;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /items = (yellow, blue)&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /replace = false&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /selectionrate = trial&lt;br/&gt;&amp;lt;/list&amp;gt;&lt;br/&gt;&lt;br/&gt;for the items to be interpreted as colors.&lt;br/&gt;</description><pubDate>Fri, 31 Oct 2014 09:53:19 GMT</pubDate><dc:creator>Dave</dc:creator></item><item><title>RE: If statements within trial's /stimulusframes?</title><link>https://forums.millisecond.com/Topic14792.aspx</link><description>My mistake I had since fixed that error. &amp;nbsp;The other error is unrelated to that I think.&lt;br/&gt;&lt;br/&gt;It is the element "text.highnumber" showing the error.</description><pubDate>Fri, 31 Oct 2014 09:25:23 GMT</pubDate><dc:creator>DCole9</dc:creator></item><item><title>RE: If statements within trial's /stimulusframes?</title><link>https://forums.millisecond.com/Topic14791.aspx</link><description>/ontrialbegin = [if &lt;strong&gt;(&lt;/strong&gt;(values.diceoutcome &amp;gt; 50 ) values.highnumcolor = list.highdemandcolor.nextvalue]&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Notice the additional (superfluous / unmatched) parenthesis.&lt;br/&gt;</description><pubDate>Fri, 31 Oct 2014 09:16:57 GMT</pubDate><dc:creator>Dave</dc:creator></item><item><title>RE: If statements within trial's /stimulusframes?</title><link>https://forums.millisecond.com/Topic14790.aspx</link><description>That's perfect Dave!&lt;br/&gt;&lt;br/&gt;One other (I think simple) question: In my code do you know why I am receiving the 'Expression " is invalid. Expression is empty.' error message? &amp;nbsp;I have a text element declared that gets filled when a list cycles values, which I've done before, but it isn't working this time.</description><pubDate>Fri, 31 Oct 2014 09:12:53 GMT</pubDate><dc:creator>DCole9</dc:creator></item><item><title>RE: If statements within trial's /stimulusframes?</title><link>https://forums.millisecond.com/Topic14789.aspx</link><description>Yes, it's possible. You need to use the &amp;lt;trial&amp;gt; element's insertstimulustime() etc. functions to do this. You cannot use &amp;lt;values&amp;gt; in the way you sketched.&lt;br/&gt;&lt;br/&gt;See e.g. &lt;a href="https://www.millisecond.com/forums/Topic10374.aspx#bm11148"&gt;https://www.millisecond.com/forums/Topic10374.aspx#bm11148&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;For further details, see the language reference for the functions mentioned above.&lt;br/&gt;</description><pubDate>Fri, 31 Oct 2014 09:05:42 GMT</pubDate><dc:creator>Dave</dc:creator></item></channel></rss>