LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

How to use global variables in a DEF block with multiple arguments and outputs?

Root / Programming Questions / [.]

🔒
mystman12Created:
I have a DEF block in my program that gets four arguments and outputs three variables. However, I also need access to a couple of arrays in the program. Is this possible without just adding the arrays as arguments in the function?

variables are always global, unless they are defined inside a function before being defined outside.

Hmm... That's weird. I'm getting an "Uninitialized variable used in 0:608" error on my program. Line 608 is where the function is being called:
CLLSN PX,PVX,PY,PVY OUT PVX,PVY,PG
All of those variables have been initialized. I assumed the error was actually coming from inside the DEF block, because the function carries out fine until it tries reading from some global arrays:
IF TILE[OFSX,OFSY,MAP[TX,TY,0]]!=0 THEN
Variables OFSX,OFSY,TX and TY have all been initiated in the function... Anyways, thanks for the help so far. I didn't realize global variables worked like that, so that's good to know!

ooh, you got the "mystery error" it happens when you don't define the output of a function CLLSN PX,PVX,PY,PVY OUT PVX,PVY,PG I think you also need to use different variables for the output

ooh, you got the "mystery error"
This is probably the best thing you've ever said on this forum And yeah send the code to that DEF block because there's certainly a bug in there

Wow, that's weird. I just managed to fix it, but... I don't know how. I added G=0 near the beginning of the DEF block, and somehow that fixed it... Even though there was another place where I had a G=1. I really have no idea what was going, but at least it's working right now!