[Solved] Using multi-line expressions

(Thomas Morley) #1

There appears to be some issues with multi-line expressions in Win 10 and 2.3.13 a simple expression like this gives an error but will work sometimes after ignoring the error warning. Error happens in Ubuntu Studio as well.

if frame < 150:
	return frame * 10
	return 150 * 10

(Thomas Morley) #3

The forums removed the tabs but the code is fine.

(Mica) #4

You can use markdown code blocks to format your code. I edited your post to add the necessary backticks to demarcate the code block.

(Frédéric Devernay) #5

Does this also happen on Win 7 (I don’t have Win 10)

(Frédéric Devernay) #6

And what if you add a blank line at the end?

(Thomas Morley) #7

I don’t have Win 7 but I’ll try the same code on Ubuntu and get back to you.

Adding a line at the bottom gives the same error.

(Thomas Morley) #8

I just tested it on Linux Ubuntu Studio 10 and I get the same error. The code works fine just gives the error when you click okay after inputting the expression.

(Frédéric Devernay) #9

This expression is incorrect. Multi-line expressions look like this:

if frame < 150:
	ret = frame * 10
	ret = 150 * 10

See the tooltip for the “Multi-line” button:
"When checked the Python expression will be interpreted as series of statement. The return value should be then assigned to the ret variable. When unchecked the expression must not contain any new line character and the result will be interpreted from the interpretation of the single line.

(Thomas Morley) #10

Glad it was just my lack of knowledge, Thank you for looking into it Fred.

(Frédéric Devernay) #11

next version will prevent earlier against using return in an expression.