﻿<?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  » Surprising behavior when referencing totalcount attribute</title><generator>InstantForum 2017-1 Final</generator><description>Millisecond Forums</description><link>https://forums.millisecond.com/</link><webMaster>Millisecond Forums</webMaster><lastBuildDate>Sun, 13 Sep 2026 11:38:31 GMT</lastBuildDate><ttl>20</ttl><item><title>Surprising behavior when referencing totalcount attribute</title><link>https://forums.millisecond.com/Topic30468.aspx</link><description>Hi all,&lt;br/&gt;&lt;br/&gt;I was building a script that was meant to take user-defined numbers of blocks flexibly and ran into a surprising issue. It's easily worked around, but I was wondering whether this was expected behavior. &lt;br/&gt;&lt;br/&gt;The issue is that when I branch a block to repeat itself until its totalcount reaches a certain value, I get one more block than I would get trials that I set up the same way. So the following code produces three blocks, but two trials per block, even though both values are set to 2:&lt;br/&gt;&lt;br/&gt;[code]&amp;lt;values&amp;gt;&lt;br/&gt;/ DesiredNumberOfBlocks = 2&lt;br/&gt;/ DesiredNumberOfTrials = 2&lt;br/&gt;&amp;lt;/values&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;expt Tester&amp;gt;&lt;br/&gt;/ blocks = [1=TestBlock]&lt;br/&gt;&amp;lt;/expt&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;block TestBlock&amp;gt;&lt;br/&gt;/ trials = [1=TestTrial]&lt;br/&gt;/ branch = [if !(trial.TestTrial.response == "Ctrl+'B'") &amp;amp;&amp;amp; (block.TestBlock.totalcount &amp;lt; values.DesiredNumberOfBlocks) block.TestBlock]&lt;br/&gt;&amp;lt;/block&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;trial TestTrial&amp;gt;&lt;br/&gt;/ stimulustimes = [0 = TestText]&lt;br/&gt;/ validresponse = (" ")&lt;br/&gt;/ branch = [if (script.currentblock == "TestBlock" &amp;amp;&amp;amp; trial.TestTrial.count &amp;lt; values.DesiredNumberOfTrials) trial.TestTrial]&lt;br/&gt;&amp;lt;/trial&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;text TestText&amp;gt;&lt;br/&gt;/ items = ("Current Block count: &amp;lt;%block.TestBlock.count%&amp;gt;&lt;br/&gt;Current Block totalcount: &amp;lt;%block.TestBlock.totalcount%&amp;gt;&lt;br/&gt;&lt;br/&gt;Current Trial count: &amp;lt;%trial.TestTrial.count%&amp;gt;&lt;br/&gt;Current Trial totalcount: &amp;lt;%trial.TestTrial.count%&amp;gt;")&lt;br/&gt;&amp;lt;/text&amp;gt;[/code]&lt;br/&gt;&lt;br/&gt;It looks as though the block's totalcount attribute is updating itself &lt;i&gt;after &lt;/i&gt;the branch is evaluated, but the trial's totalcount is doing so &lt;i&gt;beforehand&lt;/i&gt;. Is this working as intended? Or am I just missing something really basic?&lt;br/&gt;</description><pubDate>Mon, 11 Jan 2021 12:40:39 GMT</pubDate><dc:creator>AKrishna</dc:creator></item></channel></rss>