﻿<?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  » Problem getting If statement to work properly</title><generator>InstantForum 2017-1 Final</generator><description>Millisecond Forums</description><link>https://forums.millisecond.com/</link><webMaster>Millisecond Forums</webMaster><lastBuildDate>Mon, 21 Sep 2026 20:41:26 GMT</lastBuildDate><ttl>20</ttl><item><title>Problem getting If statement to work properly</title><link>https://forums.millisecond.com/Topic14834.aspx</link><description>I'm having a problem getting the following if statement to change a value correctly. &amp;nbsp;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. &amp;nbsp; 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. &amp;nbsp;&lt;br/&gt;"/ontrialbegin = [if ((values.randomposition == 1) &amp;amp;&amp;amp; (values.response == "patch1") &amp;amp;&amp;amp; (values.randomdemand == "lowpatch1" )) {values.lownumbery = 40%; values.highnumbery = 60%}]"&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Additionally I'm having &amp;nbsp;similar problem but using an if statement to insert stimulus frames. &amp;nbsp;An example is-&lt;br/&gt;/ontrialbegin = [if ((values.randomposition == 1) &amp;amp;&amp;amp; (values.response == patch2) &amp;amp;&amp;amp; (values.randomdemand == "lowpatch1")) &lt;br/&gt;{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); }]"&lt;br/&gt;</description><pubDate>Mon, 03 Nov 2014 14:23:15 GMT</pubDate><dc:creator>DCole9</dc:creator></item><item><title>RE: Problem getting If statement to work properly</title><link>https://forums.millisecond.com/Topic14843.aspx</link><description>D'oh! &amp;nbsp;That was it! &amp;nbsp;I had never needed to specify the element type before when specifying stimulus frames. &amp;nbsp;I guess if you do insert or set stimulus frames then you need to but for the /stimulusframes tag you do not.&lt;br/&gt;&lt;br/&gt;Thanks so much!</description><pubDate>Mon, 03 Nov 2014 14:23:15 GMT</pubDate><dc:creator>DCole9</dc:creator></item><item><title>RE: Problem getting If statement to work properly</title><link>https://forums.millisecond.com/Topic14841.aspx</link><description>What are those errors specifically?&lt;br/&gt;&lt;br/&gt;Note that the syntax in the functions is partly incorrect: Suppose you want to set a &amp;lt;text&amp;gt; stimulus called mytext. Then that's&lt;br/&gt;&lt;br/&gt;setstimulusframe(text.mytext, 1)&lt;br/&gt;&lt;br/&gt;not&lt;br/&gt;&lt;br/&gt;setstimulusframe(mytext, 1)&lt;br/&gt;</description><pubDate>Mon, 03 Nov 2014 14:09:25 GMT</pubDate><dc:creator>Dave</dc:creator></item><item><title>RE: Problem getting If statement to work properly</title><link>https://forums.millisecond.com/Topic14840.aspx</link><description>Thanks for the tip with the expressions Dave that helped. &amp;nbsp;I'm receiving some errors with inserting the stimulus frames even though the if statements are returning true. &amp;nbsp;Is there something wrong with the syntax?&lt;br/&gt;&lt;br/&gt;"/ontrialbegin = [if ((values.randomposition == "1") &amp;amp;&amp;amp; (values.response == "patch1") &amp;amp;&amp;amp; (values.randomdemand == "lowpatch1")) &lt;br/&gt;{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)}]"&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;</description><pubDate>Mon, 03 Nov 2014 14:02:39 GMT</pubDate><dc:creator>DCole9</dc:creator></item><item><title>RE: Problem getting If statement to work properly</title><link>https://forums.millisecond.com/Topic14839.aspx</link><description>If you want to check if or if not any of your conditions evaluates to true, you can add&lt;br/&gt;&lt;br/&gt;&amp;lt;expressions&amp;gt;&lt;br/&gt;/c1 = ((values.randomposition == 1) &amp;amp;&amp;amp; (values.response == "patch1") &amp;amp;&amp;amp; (values.randomdemand == "lowpatch1" )) &lt;br/&gt;/c2 = ((values.randomposition == 1) &amp;amp;&amp;amp; (values.response == "patch2") &amp;amp;&amp;amp; (values.randomdemand == "highpatch1" ))&lt;br/&gt;/c3 = ((values.randomposition == 2) &amp;amp;&amp;amp; (values.response == "patch1") &amp;amp;&amp;amp; (values.randomdemand == "lowpatch1" )) &lt;br/&gt;/c4 = ((values.randomposition == 2) &amp;amp;&amp;amp; (values.response == "patch2") &amp;amp;&amp;amp; (values.randomdemand == "highpatch1" ))&lt;br/&gt;&amp;lt;/expressions&amp;gt;&lt;br/&gt;&lt;br/&gt;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&lt;br/&gt;&lt;br/&gt;((values.randomposition == 1) &amp;amp;&amp;amp; (values.response == "patch1") &amp;amp;&amp;amp; (values.randomdemand == "highpatch1"))&lt;br/&gt;&lt;br/&gt;A statement such as&lt;br/&gt;&lt;br/&gt;/ontrialbegin = [if ((values.randomposition == 1) &amp;amp;&amp;amp; (values.response == &lt;span style="text-decoration: underline;"&gt;&lt;span style="font-style: italic;"&gt;&lt;strong&gt;patch1&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;) &amp;amp;&amp;amp; (values.randomdemand == "lowpatch1")) &lt;br/&gt;&lt;br/&gt;will fail to evaluate to true due to missing double-quotes.&lt;br/&gt;</description><pubDate>Mon, 03 Nov 2014 13:14:23 GMT</pubDate><dc:creator>Dave</dc:creator></item></channel></rss>