Notifications
Clear all

[Closed] Missing Variable that's defined and Global?

So I have a script which is layed out as such.

filein: 4 scripts which include the struct and function definitions needed for the script.

4 lines of code which initialize those structs

var = varstruct()
etc…

and then I create a newRolloutFloater

Create Two Rollouts

and attempt to addrollout 1 and 2 to the floater.

The first one attaches fine.
The second one when it attempts to run a VERY basic function in the “on open” call can’t see any global variables.

In the debugger even the dialog variable of which it’s a member is listed as “undefined”! Even though right before running the “addrollout rollout02…” code I can check in the listener and all of the relevant variables are defined! What gives? Even a piece of code which is defined a the top of the script as global isn’t being seen by the function! Is it because I’m “including” the function as part of a struct from another script?

Of course on the second execution everything works perfectly so it’s a case of “first run of max”.

What’s even more absurd is what variable isn’t being found… THE VARIABLE THAT CONTAINS THE FUNCTION.

So I have

struct structbob (fn functionjim = (print mike), mike = “hello”)
bobvar = structbob()

on rollout open do
(
bobvar.functionjim()
)

“Unknown property: “mike” in undefined”

and then proceeds to list the bobvar as undefined in the debugger!

2 Replies

Ughhhhhhh…

Solution:
Place Global Definitions Above FileIn() lines.

I’m just going to pretend to understand why that solves the problem. Even though all the fileIns are just defining global struct definitions as well.

lol, I guess it makes sense? Nah, I don’t really understand it either, but it’s conforting to know I’m not the only one…

-Colin