Millisecond Forums

Using replace function in position parameter throws syntax error

https://forums.millisecond.com/Topic12014.aspx

By ImponDeRable - 1/2/2014

Hello Inquisitors!

I have a relatively simple problem but could not get my head around why my approach does not work.

Inquisit documentation gives a following example of using replace() function to get randomized picture position:

<picture mypic>
/ items = ("foo.jpg")
/ position = (replace(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100), replace(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100))
</picture>


In my experiment I use the same syntax:
<picture negpic>
/ items = neg
/ position = (replace(15, 85), 50)
</picture>

but it gives me following errors:
Element: picture.negpic
Attribute: position
Message: Setting has invalid text ', 50)'.

Element: picture.negpic
Attribute: 
Message: Expression 'replace(15,' is invalid. Unmatched parenthesis.


However, my parentheses are matched, I have also checked around
(before the definition of the picture and after) and everything seems to
be a legitimate Inquisit syntax.
I have also tried using ';' instead of ',' or adding spaces - the error is the same.

Do you have any ideas why it might not work or what should be done to fix the problem?

By Dave - 1/2/2014

Where does the documentation give those examples?
By Dave - 1/2/2014

To clarify, the correct way to do this would be

<block myblock>
/ trials = [1-10=mytrial]
</block>

<trial mytrial>
/ stimulusframes = [1=mytext]
/ validresponse = (57)
</trial>

<text mytext>
/ items = ("A")
/ hposition = replace(25%, 75%)
/ vposition = replace(10%, 50%, 90%)
</text>

or alternatively

<block myblock>
/ trials = [1-10=mytrial]
</block>

<trial mytrial>
/ stimulusframes = [1=mytext]
/ validresponse = (57)
</trial>

<text mytext>
/ items = ("A")
/ position = (expressions.randpos, 40%)
</text>

<expressions>
/ randpos = replace(25%, 75%)
</expressions>


The syntax in your /position attribute(s) is in fact not valid, as far as I am aware.
By ImponDeRable - 1/2/2014

By documentation I mean the full documentation of inquisit objects,
otherwise known as help. :)

You can find it under:
Help --> Table of contents

then in the table of contents:
Language Reference --> Expressions --> Functions

And then under selection functions there are examples where
this way of using replace() is presented.
By Dave - 1/2/2014

Yes, I am well aware of the functions reference. However, I don't think any example gives the use case you are alleging in the /position attribute:

"Inquisit documentation gives a following example of using replace() function to get randomized picture position:

<picture mypic>
/ items = ("foo.jpg")
/ position = (replace(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100), replace(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100))
</picture>"

I have posted valid examples in my previous response.
By Dave - 1/2/2014

I stand corrected. The functions reference does indeed give that flawed example, which I had overlooked at first. Thanks for pointing this out -- I will make sure the example gets replaced with a valid one.
By ImponDeRable - 1/2/2014

Thanks a lot, Dave!
Especially for the correct examples that you've posted before in this tread,
they will save me some time.
By seandr - 1/8/2014

Documentation will be corrected in the next update.

Thanks,
Sean