﻿<?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  » solution to multiple if statements not working</title><generator>InstantForum 2017-1 Final</generator><description>Millisecond Forums</description><link>https://forums.millisecond.com/</link><webMaster>Millisecond Forums</webMaster><lastBuildDate>Sat, 19 Sep 2026 08:30:29 GMT</lastBuildDate><ttl>20</ttl><item><title>solution to multiple if statements not working</title><link>https://forums.millisecond.com/Topic19795.aspx</link><description>Hello,&lt;br/&gt;I ran into issues using multiple if statements in inquisit version 4 that I solved myself, but could not find the solution documented anywhere, so I thought I'd share.&lt;br/&gt;&lt;br/&gt;When using multiple if statements in, for example, ontrialend, they cannot all be placed in the same on trial end section or else I believe only the first will run.&lt;br/&gt;ie. this will NOT work:&lt;br/&gt;/ ontrialend = [&lt;br/&gt;if (correct==1) {values.response = 1}&lt;br/&gt;else {values.response = 2} &lt;br/&gt;&lt;br/&gt;if (latency &amp;gt; values.resp_window) {values.inwindow = 0;}&lt;br/&gt;else {values.inwindow = 1;}&lt;br/&gt;]&lt;br/&gt;&lt;br/&gt;Instead they must be placed in separate ontrialend sections:&lt;br/&gt;&lt;br/&gt;&lt;span style="color: rgb(34, 34, 34); font-family: arial, tahoma; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;"&gt;/ ontrialend = [&lt;/span&gt;&lt;br/&gt;&lt;span style="color: rgb(34, 34, 34); font-family: arial, tahoma; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;"&gt;if (correct==1) {values.response = 1}&lt;/span&gt;&lt;br/&gt;&lt;span style="color: rgb(34, 34, 34); font-family: arial, tahoma; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;"&gt;else {values.response = 2}&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;br/&gt;&lt;/span&gt;&lt;/span&gt;]&lt;br/&gt;/ ontrialend = [&lt;br/&gt;&lt;span style="color: rgb(34, 34, 34); font-family: arial, tahoma; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;"&gt;if (latency &amp;gt; values.resp_window) {values.inwindow = 0;}&lt;/span&gt;&lt;br/&gt;&lt;span style="color: rgb(34, 34, 34); font-family: arial, tahoma; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;"&gt;else {values.inwindow = 1;}&lt;/span&gt;&lt;br/&gt;&lt;span style="color: rgb(34, 34, 34); font-family: arial, tahoma; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;"&gt;]&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;</description><pubDate>Tue, 04 Oct 2016 07:49:57 GMT</pubDate><dc:creator>thv</dc:creator></item><item><title>RE: solution to multiple if statements not working</title><link>https://forums.millisecond.com/Topic19796.aspx</link><description>&amp;gt; ie. this will NOT work:&lt;br/&gt;&lt;br/&gt;&amp;gt; / ontrialend = [&lt;br/&gt;&amp;gt; if (correct==1) {values.response = 1}&lt;br/&gt;&amp;gt; else {values.response = 2} &lt;br/&gt;&amp;gt; &lt;br/&gt;&amp;gt; if (latency &amp;gt; values.resp_window) {values.inwindow = 0;}&lt;br/&gt;&amp;gt; else {values.inwindow = 1;}&lt;br/&gt;&amp;gt; ]&lt;br/&gt;&lt;br/&gt;The above doesn't work because the statements aren't properly separated, i.e., the syntax is wrong. Do&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;/ ontrialend = [&lt;br/&gt;if (correct==1) {values.response = 1}&lt;br/&gt;else {values.response = 2}&lt;strong&gt; ; &amp;lt;-Semicolon is the separator&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;if (latency &amp;gt; values.resp_window) {values.inwindow = 0;}&lt;br/&gt;else {values.inwindow = 1;}&lt;br/&gt;]&lt;br/&gt;&lt;br/&gt;and it should work just fine.&lt;br/&gt;&lt;br/&gt;See for yourself by running &lt;br/&gt;&lt;br/&gt;&amp;lt;block myblock&amp;gt;&lt;br/&gt;/ trials = [1=mytrial]&lt;br/&gt;&amp;lt;/block&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;trial mytrial&amp;gt;&lt;br/&gt;/ ontrialend = [if (values.a) {values.response = 1}&lt;br/&gt;else {values.response = 2};&lt;br/&gt;if (values.b &amp;gt; values.c) {values.inwindow = 0;}&lt;br/&gt;else {values.inwindow = 1;}&lt;br/&gt;]&lt;br/&gt;/ validresponse = (57)&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;values&amp;gt;&lt;br/&gt;/ a = false&lt;br/&gt;/ b = 3&lt;br/&gt;/ c = 4&lt;br/&gt;/ response = 0&lt;br/&gt;/ inwindow = -1&lt;br/&gt;&amp;lt;/values&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;data&amp;gt;&lt;br/&gt;/ columns = [values.a, values.b, values.c, values.response, values.inwindow]&lt;br/&gt;/ separatefiles = true&lt;br/&gt;&amp;lt;/data&amp;gt;&lt;br/&gt;&lt;br/&gt;which has the same structure as your logic.&lt;br/&gt;</description><pubDate>Tue, 04 Oct 2016 07:49:57 GMT</pubDate><dc:creator>Dave</dc:creator></item></channel></rss>