Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

if statement [variable]=None

edited April 2017 in OpenSesame

Hi all,

I have a bunch of variables in a loop (e.g., V1, V2, V3) and some items to be run by a sequence associated with that loop (e.g., item1, item2, item3). I would like the sequence to run items only if a corresponding variable is not empty. So far I tried specifying it by an if statement in the sequence:

run item1 "[V1]!=None"
run item2 "[V2]!=None"
run item3 "[V3]!=None"

But this doesn't work, probably because OS thinks I mean a string "None" rather than an expression for an empty variable. Is there another way of doing that?

Many thanks!

Jarek

Comments

  • Hi Jarek,

    I would like the sequence to run items only if a corresponding variable is not empty.

    Strictly speaking, there is no such thing as an empty variable. Either it doesn't exist, in which case you would get a "variable does not exist" error, or it exists and therefore has some value. You probably mean an empty string (''):

    run item1 "[V1] != ''"
    

    Does that help at all?

    Cheers,
    Sebastiaan

  • edited April 2017

    Hi Sebastiaan,

    Thanks for a quick reply. It does help indeed! I actually tested this solution before, but in a very sloppy way. Now I did it properly and all works well. Thank you!

  • Hi all!
    I have somehow the same problem, but the solution doesnt work for me.
    I want to have some extra pictures and questions in my desing, lets say every 3 trials. In order to define that, the variable "Extra picture" and "Extra question" are filled with "na" in the loop, lets say in the 1rst and 2nd row. The error I get is the '.jpg' file does not exist.

    My script looks like this:
    run Pract_Q1_1 "[Extra_picture] !='na '"
    run Pract_Sound1_1 "[Extra_Question] !='na'"

    I have tried also the line: =(self.get('count_trial_sequence_1')+1)%3 == 0, with no success... :(

    Any ideas?

    Thank you very much!

  • Hi Jarek,

    There a space in your code: run Pract_Q1_1 "[Extra_picture] !='na '"

    'na' is not 'na '

    Best,
    Jarik

Sign In or Register to comment.