[Solved] Using multi-line expressions

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
else:
	return 150 * 10

The forums removed the tabs but the code is fine.

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

1 Like

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

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

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.

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.

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

if frame < 150:
	ret = frame * 10
else:
	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.

1 Like

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

next version will prevent earlier against using return in an expression.
https://github.com/NatronGitHub/Natron/commit/dda6a242a5394a5c13eb82747a5be194e7737347

1 Like