10-20-2015, 07:08 PM
The scope of variables in library files change when the program is compiled. Run as a script, the variable scope is limited to the library file. once compiled, the scope increases to include the whole project unless they are declared local.
exmple:
test.yab...
#!yab
import library
for x=1 to 12
y=multiplybyfive(x)
print y
next
library file. ( library.yab)
export sub multiplybyfive (number)
y=0
for x=0 to 4
y = y + number
next
return y
end sub
Run test.yab as a script and all is well. Run it as a compiled binary and it hangs.
change the library like this:
export sub multiplybyfive (number)
local x,y
y=0
for x=0 to 4
y = y + number
next
return y
end sub
now it runs properly both as a script or compiled.
exmple:
test.yab...
#!yab
import library
for x=1 to 12
y=multiplybyfive(x)
print y
next
library file. ( library.yab)
export sub multiplybyfive (number)
y=0
for x=0 to 4
y = y + number
next
return y
end sub
Run test.yab as a script and all is well. Run it as a compiled binary and it hangs.
change the library like this:
export sub multiplybyfive (number)
local x,y
y=0
for x=0 to 4
y = y + number
next
return y
end sub
now it runs properly both as a script or compiled.