global variables

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

global variables

Postby IT2Be » Mon Mar 08, 2004 9:51 pm

Along the way of developing my solution I clean up things every once and a while.

Now I noticed that it is very easy to delete a global without any issue. But ok, that's my own mistake. I should have paid more attention :D

But, when a global variable is not defined but I try to set it there is no error message.

Also when I try to get the value one gets a null value and outputting it to the debugger with application.output(global.variable) gives the message undefined...

Can we please get an error message if the global variable is not there?
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby jcompagner » Tue Mar 09, 2004 2:04 pm

we can do 2 things.

1> throw an error if you set something in the globalscope that isn't there as a real global..

2> just add it in the globalscope so you can use it further on.


We can't do anything about getting a global that isn't there.
That is just how javascript works.. (returning undefined (null))
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8868
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby pbakker » Tue Mar 09, 2004 2:08 pm

Do i understand this correctly: does option 2 give you the option for dynamically create a global variable? Would be a handy option.....

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby IT2Be » Tue Mar 09, 2004 2:08 pm

If I understand correct something like global.variable = false can throw an error if global.variable it non existing?

If so, I prefer this...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby jcompagner » Tue Mar 09, 2004 2:24 pm

we discussed this and we prefer also option 2..

so you can say:

globals.XXXX = 'YYYY'

because that is much neater then for example just saying

XXXX = 'YYYY'

and then use XXXX all over the place..

with the globals prefix you know what you doing and is much more structured..
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8868
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 7 guests