If I try to use the {IF ... statement in any script S3D V5.0.2 doesn't interpret it and (if true) just put the gCode after the closing bracket "}" into the gCode output file but the whole line including everything inside the brackets, no matter if it's true or not.
Here's an example which I use in the post tool change script for my Snapmaker J1:
{IF NEWTOOL=0}G1 X[next_position_x] Y[next_position_y] F9000 ; go to next position at high speed
{IF NEWTOOL=1}G1 X[current_position_x] Y[current_position_y] F9000 ; go to next position at high speed
Depending on which tool is the next one it should put one of the following two lines (the 100s just as example coordinates) into the gCode output file, not one of the full above lines:
G1 X100 Y100 F9000 ; go to next position at high speed
G1 X100 Y100 F9000 ; go to next position at high speed
This is clearly a new bug, it worked in similar use cases in V4.x.