Surprising behavior when referencing totalcount attribute


Author
Message
AKrishna
AKrishna
Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)Distinguished Member (3.8K reputation)
Group: Forum Members
Posts: 118, Visits: 396
Hi all,

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.

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:

<values>
/ DesiredNumberOfBlocks = 2
/ DesiredNumberOfTrials = 2
</values>

<expt Tester>
/ blocks = [1=TestBlock]
</expt>

<block TestBlock>
/ trials = [1=TestTrial]
/ branch = [if !(trial.TestTrial.response == "Ctrl+'B'") && (block.TestBlock.totalcount < values.DesiredNumberOfBlocks) block.TestBlock]
</block>

<trial TestTrial>
/ stimulustimes = [0 = TestText]
/ validresponse = (" ")
/ branch = [if (script.currentblock == "TestBlock" && trial.TestTrial.count < values.DesiredNumberOfTrials) trial.TestTrial]
</trial>

<text TestText>
/ items = ("Current Block count: <%block.TestBlock.count%>
Current Block totalcount: <%block.TestBlock.totalcount%>

Current Trial count: <%trial.TestTrial.count%>
Current Trial totalcount: <%trial.TestTrial.count%>")
</text>


It looks as though the block's totalcount attribute is updating itself after the branch is evaluated, but the trial's totalcount is doing so beforehand. Is this working as intended? Or am I just missing something really basic?

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View

Reading This Topic

Explore
Messages
Mentions
Search