Bug in /stop 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
Dear all,

I think I've stumbled on a bug: the / stop attribute (at least in expt elements) is sometimes not evaluated correctly. The following code provides an example:

<values>
/ TestStop = false
/ OtherStop = false
</values>

<expt MinimalExample>
/ blocks = [1 = HelloWorld]
/ stop = [
    values.TestStop; values.OtherStop
]
</expt>

<block HelloWorld>
/ trials = [1 = HelloWorld]
</block>

<trial HelloWorld>
/ stimulustimes = [0 = HelloWorld]
/ timeout = 2000
</trial>

<text HelloWorld>
/ items = ("Hello World!")
</text>


This runs as expected, the trial is displayed. The / stop attribute is expected to fire if EITHER values.TestStop OR values.OtherStop OR both are true, preventing the trial from displaying.

If only OtherStop is true or if both are true, /stop acts as expected. However, if ONLY TestStop is true, the stop condition doesn't fire and the trial displays.

For now, a workaround would be to avoid listing /stop statements with semicolons and instead connect them via || (or) operators:

<expt MinimalExample>
/ blocks = [1 = HelloWorld]
/ stop = [
    values.TestStop || values.OtherStop
]
</expt>



Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
AKrishna - 9/13/2024
Dear all,

I think I've stumbled on a bug: the / stop attribute (at least in expt elements) is sometimes not evaluated correctly. The following code provides an example:

<values>
/ TestStop = false
/ OtherStop = false
</values>

<expt MinimalExample>
/ blocks = [1 = HelloWorld]
/ stop = [
    values.TestStop; values.OtherStop
]
</expt>

<block HelloWorld>
/ trials = [1 = HelloWorld]
</block>

<trial HelloWorld>
/ stimulustimes = [0 = HelloWorld]
/ timeout = 2000
</trial>

<text HelloWorld>
/ items = ("Hello World!")
</text>


This runs as expected, the trial is displayed. The / stop attribute is expected to fire if EITHER values.TestStop OR values.OtherStop OR both are true, preventing the trial from displaying.

If only OtherStop is true or if both are true, /stop acts as expected. However, if ONLY TestStop is true, the stop condition doesn't fire and the trial displays.

For now, a workaround would be to avoid listing /stop statements with semicolons and instead connect them via || (or) operators:

<expt MinimalExample>
/ blocks = [1 = HelloWorld]
/ stop = [
    values.TestStop || values.OtherStop
]
</expt>



So, it's not a bug, but the documentation is unclear / somewhat wrong on this. Each /stop attribute is evaluated as a whole, and whatever the final result is the return value and determines whether a stop occurs or not.

With

<values>
/ TestStop = true
/ OtherStop = false
</values>


and

/ stop = [
    values.TestStop;
    values.OtherStop;
]


the return value is false per values.OtherStop.

With

/ stop = [
    return values.TestStop;
]
/ stop = [
    return values.OtherStop;
]


the return value of the first /stop attribute is true per values.TestStop, so a stop occurs. The 2nd stop attribute is not evaluated.

You can have multiple expressions in a single /stop attribute to achieve the same thing, e.g.

/ stop = [
    if (values.TestStop) {
        return true;
    };
    if (values.OtherStop) {
        return true
    };
]


The first conditional applies and returns true, the 2nd conditional does not apply, so nothing changes.

And finally, as you noted, you can of course use a logical OR, which I would consider the clearest specification.

/ stop = [
    return (values.TestStop || values.OtherStop)
]


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search