Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Strange issues with global variables

Avatar

16-03-2009

Hello

I encountered some problems while trying to work with global variables.

Sometimes it happens that when I want to get the value of a variable, it just returns 'undefined' or 'NaN'...

All I did was declaring a global variable (File -> Form properties and also global.xyz = ...; on the initialize event of Document1, I've used both methods) and adding +1 to it when pressing a button.

This would look like:

--------------------------------------------

global.test = 0; (Document initialization)



app.alert(global.test); (Button click event)

global.test++;

--------------------------------------------



The strange thing is: Sometimes I can count up to values greater than 50 before the program "loses" the variable, sometimes it happens already at 10 or below and in other cases it is undefined already when I open the document.

However, I did not change anything in my script.



Is there another way to declare and use global variables?

May it also be possible that these problems are normal when you use the trial version of LiveCycle Designer ES?

Replies

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

16-03-2009

The variable should be accessed using its value property like this:



VariableName.value = 1



The trial version of Designer has nothing to do with this.

Avatar

19-03-2009

I figured out that my problem no longer exists when I uncheck the option "Strict Scoping rules for JavaScript" in File -> Form properties -> standards.

Can someone tell me what this means in detail? Should I expect some further problems when working with this option turned off?

Is it even recommendable to turn it off?

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

611 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

19-03-2009

Script scoping rules was adding in version 8.1 (I think). It defines a level of acceptance for writing javascript code. In earlier version you could take short cuts that would not be syntactically correct but would run anyways. If that is checked on the rules for scripting are enforced to the max.



That setting may have something to do with the scoping of your vars....but I am not sure.