PDA

View Full Version : global variable call


Hobbs
04-30-2007, 11:40 PM
I have a code where I have 2rc menu's and then a rollout. I declare the rollout globally before the rollout.

so the order goes
rcmenu
rcmenu
--global decloration of rollout
rollout

In the rcmenu code i call the rollout by its global call to get to its combobox

Library.pallete.items.

On other people's computer it gets an error message saying that "pallete" is undefined.
But on mine it works.

Could it be that i'm not declaring my rollout as global at the top of my script, or could it possibly be something else?

Thanks.

Bobo
05-01-2007, 04:44 AM
The global declaration of the rollout should be BEFORE the two RC menus if the menus are supposed to "see" the rollout.
If you run the script twice, it will probably start working on any machine, but the trick is to make it run the first time correctly...

Pjanssen
05-01-2007, 08:06 AM
Perhaps slightly off topic, but a method I always find useful is putting all the UI things in a struct, so that you can use just one global for all UI elements:

struct myUI (
rcmenu firstRC (
--code here
)

rcmenu secondRC (
--code here
)
)
global myUI = myUI();

With that done, you can call anything inside the structure by using:
myUI.firstRC
--or:
myUI.secondRC

MoonDoggie
05-01-2007, 02:18 PM
global rlt_main

rcmenu1 (
// access rollouts with rlt_name.rlt_element like
// rlt_main.btn_Press.width = 200
)

rcmenu2 (
)

rlt_main (
button btn_Press "Press me"
)

MoonDoggie
05-01-2007, 02:18 PM
In the above example there is no need for a structure and you accomplish the same thing.

Hobbs
05-01-2007, 03:21 PM
Thanks for clearing that up for me :thumbsup:. The struct idea seems like a good thing to implement as well, hadn't thought of that.

Pjanssen
05-01-2007, 05:20 PM
In the above example there is no need for a structure and you accomplish the same thing.
True, for a just one or two things that you want to be global it's more simple indeed. For more complex things a structure might be easier, as you can access everything within the structure globally, with just one global variable.

MoonDoggie
05-01-2007, 05:39 PM
true, and certainly worth mentioning. Many thanks.

CGTalk Moderation
05-01-2007, 05:39 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.