How to access variables out of a subroutine?

Hi.

I’m currently having issues with my script and it goes something like this (It’s a script for the Textual / Linkinus IRC Client). Since I’m not on the Mac right now, it might have some syntax errors, but I assure you that that’s my fault and on the script they’re correctly written.


property thename = MyScript
Global mystrangetext


set mystrangetext to "Yaddah Baddah"

on textualcmd(cmd)
return mystrangetext
end textualcmd

on linkinuscmd(cmd)
return mystrangetext
end linkinuscmd

This won’t work. But if I do a


on textualcmd(cmd)
return thename
end textualcmd

instead, it works, correctly outputting the property value.

Help?

This works, it returns “Yaddah Baddah”:

property thename : "MyScript"
global mystrangetext

set mystrangetext to "Yaddah Baddah"
textualcmd("dummy")

on textualcmd(cmd)
	return mystrangetext
end textualcmd

on linkinuscmd(cmd)
	return mystrangetext
end linkinuscmd

Sorry, but with a half correct written script I won’t spend time figuring this one out (yet). First make sure you’re code is syntax-wise correct before we continue more in depth.