PDA

View Full Version : Global Arrays & Variables



baushaug
6 Apr 2012, 9:29 AM
I attempting to create a global or application specific array with in my launch:function().



launch: function() {
BrookshireBrothersMobile.globals = {
enduser: '',
dummy: 35
};
Ext.create('BrookshireBrothersMobile.view.Main', {fullscreen: true});
}


Although when I attempt to retrieve either one of these variables within a Controller Action, I get this Reference Error


ReferenceError

arguments: Array[1]

0: "enduser"
length: 1
__proto__: Array[0]

get message: function getter() { [native code] }
get stack: function getter() { [native code] }
set message: function setter() { [native code] }
set stack: function setter() { [native code] }
type: "not_defined"
__proto__: Error


Also what is the proper way to declare an application specific or global array in the launch function?

Are there any examples of this in the sample code ?

aconran
6 Apr 2012, 10:00 AM
This looks fine... and I assume to access it you are doing

BrookshireBrothersMobile.globals.enduser?

baushaug
6 Apr 2012, 11:06 AM
Thanks for the response Aaron.


I tried that and now I get a TypeError

TypeError

arguments: Array[2]

0: "enduser"
1: undefined
length: 2
__proto__: Array[0]

get message: function getter() { [native code] }
get stack: function getter() { [native code] }
set message: function setter() { [native code] }
set stack: function setter() { [native code] }
type: "non_object_property_load"
__proto__: Error

aconran
6 Apr 2012, 11:20 AM
Has launch run?

Step through with a debugger and/or some console.log/alert statements

baushaug
6 Apr 2012, 11:32 AM
Well here is where my novice experience with this technology hinders my comprehension.

I assumed launch had run since it's within the "Application Entry Point" which I associate with the main() method of a console application implemented in an actual programming language such as C, C# or whatever.

Since it's a function I should be able to call it, correct ?

Or how does one make launch "run" ?

aconran
6 Apr 2012, 11:56 AM
It should run automatically.

You can put a console.log in and check out the console or set a breakpoint via a debugger; statement

baushaug
6 Apr 2012, 12:06 PM
That's what I was thinking.

I placed a console.log within the launch method, so I know it's not running.

I'm not sure how to set breakpoints ?

aconran
6 Apr 2012, 1:37 PM
Application launch should be getting run... maybe you are hitting some syntax error. Does any error occur?

baushaug
6 Apr 2012, 1:43 PM
No, not when I look in the Chrome's Console. I see a few warnings from having some components with the same id but no errors.

aconran
6 Apr 2012, 1:52 PM
I'd gladly take a look at your project, but without it I'm shooting a bit in the dark. Does your app launch? or you just get a blank screen?

baushaug
6 Apr 2012, 2:08 PM
It launches.

I did compress these files but the compression of 1.11MB exceeds the forum's limit 488.3.

Can I email you or is there another way to send you the project ?

aconran
6 Apr 2012, 2:33 PM
desinger . feedback at sencha . com

baushaug
6 Apr 2012, 5:26 PM
Thanks.

I got that sent off finally.

Let me know if you need anything else?