﻿<?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 5  » ontrialend not reading response correctly?</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 03:32:38 GMT</lastBuildDate><ttl>20</ttl><item><title>ontrialend not reading response correctly?</title><link>https://forums.millisecond.com/Topic20853.aspx</link><description>Currently, I'm running a task where the participant makes a choice, and a master budget updates by subtracting the price of the selection. However, I noticed that even when pressing "z" only to move on, the conditional in the ontrailend part always goes to the "else" (and updates accordingly). Am I missing something here?&lt;br/&gt;&lt;br/&gt;&amp;lt;trial recipe_trial&amp;gt;&lt;br/&gt;/ validresponse = ("z", "m")&lt;br/&gt;/ stimulusframes = [1 = recipe1, recipe2, recipe1_price, recipe2_price, progress]&lt;br/&gt;/ ontrialend = [&lt;br/&gt;if (trial.recipe_trial.response == "z") {&lt;br/&gt;values.current_budget = values.current_budget - list.recipe1_prices.item(picture.recipe1.currentindex)&lt;br/&gt;}&lt;br/&gt;else {&lt;br/&gt;values.current_budget = values.current_budget - list.recipe2_prices.item(picture.recipe1.currentindex)&lt;br/&gt;}&lt;br/&gt;]&lt;br/&gt;/ posttrialpause = 250&lt;br/&gt;&amp;lt;/trial&amp;gt;</description><pubDate>Thu, 23 Feb 2017 07:20:41 GMT</pubDate><dc:creator>mzhang13</dc:creator></item><item><title>RE: ontrialend not reading response correctly?</title><link>https://forums.millisecond.com/Topic20856.aspx</link><description>&lt;div data-id="20853" class="if-quote-wrapper" unselectable="on" data-guid="1487863009485"&gt;&lt;a class="quote-para" unselectable="on" style="display: none;" href="#" data-id="20853" title="Move Cursor Below" contenteditable="false"&gt;&lt;span unselectable="on"&gt;+&lt;/span&gt;&lt;/a&gt;&lt;a class="quote-delete" unselectable="on" style="display: none;" href="#" data-id="20853" title="Delete Quote" contenteditable="false"&gt;&lt;span unselectable="on"&gt;x&lt;/span&gt;&lt;/a&gt;&lt;span unselectable="on" class="quote-markup"&gt;[quote]&lt;/span&gt;&lt;div unselectable="on" class="if-quote-header" contenteditable="false"&gt;&lt;div unselectable="on" class="if-quote-toggle-wrapper"&gt;&lt;a class="if-quote-toggle quote-link" href="#" data-id="20853" title=" "&gt;&lt;/a&gt;&lt;/div&gt;&lt;span unselectable="on" class="quote-markup"&gt;[b]&lt;/span&gt;mzhang13 - Wednesday, February 22, 2017&lt;span unselectable="on" class="quote-markup"&gt;[/b]&lt;/span&gt;&lt;/div&gt;&lt;div class="if-quote-message if-quote-message-20853"&gt;&lt;div class="if-quote-message-margin"&gt;Currently, I'm running a task where the participant makes a choice, and a master budget updates by subtracting the price of the selection. However, I noticed that even when pressing "z" only to move on, the conditional in the ontrailend part always goes to the "else" (and updates accordingly). Am I missing something here?&lt;br/&gt;&lt;br/&gt;&amp;lt;trial recipe_trial&amp;gt;&lt;br/&gt;/ validresponse = ("z", "m")&lt;br/&gt;/ stimulusframes = [1 = recipe1, recipe2, recipe1_price, recipe2_price, progress]&lt;br/&gt;/ ontrialend = [&lt;br/&gt;if (trial.recipe_trial.response == "z") {&lt;br/&gt;values.current_budget = values.current_budget - list.recipe1_prices.item(picture.recipe1.currentindex)&lt;br/&gt;}&lt;br/&gt;else {&lt;br/&gt;values.current_budget = values.current_budget - list.recipe2_prices.item(picture.recipe1.currentindex)&lt;br/&gt;}&lt;br/&gt;]&lt;br/&gt;/ posttrialpause = 250&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;a class="if-quote-goto quote-link" href="#" data-id="20853"&gt;&lt;span class="goto"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class="quote-markup"&gt;[/quote]&lt;/span&gt;&lt;/div&gt;&lt;br/&gt;A &amp;lt;trial&amp;gt;'s response property returns the numerical scan code of the key pressed, not the key's "literal" value (letter or other symbol). The scan code of the "z"-key on a standard English-language keyboard is 44, i.e. your statement ought to read&lt;br/&gt;&lt;br/&gt;/ ontrialend = [&lt;br/&gt;if (trial.recipe_trial.response == 44) {&lt;br/&gt;,,,&lt;br/&gt;}&lt;br/&gt;]&lt;br/&gt;&lt;br/&gt;See the "Keyboard Scan Codes" topic in the documentation and 'Tools -&amp;gt; Keyboard Scancodes...' for details.&lt;br/&gt;&lt;br/&gt;To convert the scan code to the corresponding charcter, you can also use the computer.scancodetochar() function. Like so:&lt;br/&gt;&lt;br/&gt;&amp;lt;trial recipe_trial&amp;gt;&lt;br/&gt;/ validresponse = ("z", "m")&lt;br/&gt;/ branch = [&lt;br/&gt;if (&lt;strong&gt;computer.scancodetochar(trial.recipe_trial.response) == "z"&lt;/strong&gt;) {&lt;br/&gt;trial.z&lt;br/&gt;}&lt;br/&gt;else {&lt;br/&gt;trial.m&lt;br/&gt;}&lt;br/&gt;]&lt;br/&gt;/ posttrialpause = 250&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;trial z&amp;gt;&lt;br/&gt;/ stimulusframes = [1=mytext]&lt;br/&gt;/ validresponse = (57)&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;trial m&amp;gt;&lt;br/&gt;/ stimulusframes = [1=mytext]&lt;br/&gt;/ validresponse = (57)&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text mytext&amp;gt;&lt;br/&gt;/ items = ("you pressed &amp;lt;%script.currenttrial%&amp;gt;")&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-4 = recipe_trial]&lt;br/&gt;&amp;lt;/block&amp;gt;&lt;br/&gt;</description><pubDate>Thu, 23 Feb 2017 07:20:41 GMT</pubDate><dc:creator>Dave</dc:creator></item></channel></rss>