variable scope and library files.
#1
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.
Reply


Messages In This Thread
variable scope and library files. - by bbjimmy - 10-20-2015, 07:08 PM
RE: variable scope and library files. - by clasqm - 10-21-2015, 03:31 AM
RE: variable scope and library files. - by clasqm - 10-24-2015, 02:59 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)
Free Web Hosting