Howdy, Stranger!

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

Supported by

invalid syntax

I have been working on debugging this for a while now. I am new to code, so I may be missing something simple.. Here is the message I am getting when I run the experiment. I highlighted all the things that OpenSesame put in red.

File "C:\Users\jonesfm\Desktop\OpenSesame\lib\site-packages\libopensesame\inline_script.py", line 73, in prepare
self.var.get(u'_run', _eval=False))
File "C:\Users\jonesfm\Desktop\OpenSesame\lib\site-packages\libopensesame\python_workspace.py", line 147, in _compile
return compile(script, u'', u'exec')
File "", line 4
else var.valid_pos = 'false'
^
SyntaxError: invalid syntax

Thank you!

Comments

  • if this helps, this is my inlineScript:

    if var.box_pos == var.arrow_cue:
    var.valid_pos = 'true'
    else var.valid_pos = 'false'

    if var.box_pos != var.arrow_cue:
    var.invalid_pos = 'true'
    else var.invalid_pos = 'false'

  • it might be a problem that I do not have anything in the "prepare" window. I only have it in the "run" window... What should go in the "prepare" tab?

  • edited October 2016

    Hi,

    It's never too late to start learning how to code. There are plenty of nice Python tutorials online.

    Your mistake, is that you don't adhere to Python's indentation rules and that and else is always followed by a colon. Also, your code is a little convoluted. I simplified it a little, can you see the difference? This is how it should look:

    # I hope I interpreted your intentions correctly
    if var.box_pos == var.arrow_cue:
        var.valid_pos = True
        var.invalid_pos = False
    elif var.box_pos != var.arrow_cue:
        var.invalid_pos = True
        var.valid_pos = False
    

    As a side note, if you want to use booleans (True, False and such), you have to use True and Falseand not the string trueand false.

    Eduard

    Buy Me A Coffee

  • that worked perfectly! Many many thanks!

Sign In or Register to comment.