Andrus, the results that you are seeing are exactly as expected as VIV correctly pointed out. See code example below with the equivalent function call.
cres = EXECSCRIPT('x=y') is a perfectly valid script which is returning .t. since the script does not directly return a value.
cres = EXECSCRIPT('x') generates a runtime error which is picked up by your error handler which effectively skips the line with the error which is why you do not see it setting a new value to cres.
cres = "Do Not Touch"
x = 1
y = 1
ON ERROR seterror()
cres = EXECSCRIPT('x=y')
MESSAGEBOX(cres)
cres = "Do Not Touch"
x = 1
y = 1
ON ERROR seterror()
cres = set_xtoY()
MESSAGEBOX(cres)
FUNCTION set_xtoY
x = y
return .t.
ENDFUNC
PROCEDURE seterror
RETURN TO muutsead
ENDPROC