Skip to main content
10-Marble
November 8, 2023
Solved

global variables

  • November 8, 2023
  • 1 reply
  • 920 views

Why am I getting an error when I move g below k? Shouldn't global variables work where ever they are used?

 

2.jpg  -->  1.jpg

 

so, this seems to work ... 3.jpg... So is it not possible to have global variables inside global variables? if so, why did the first set of calcs work?

 

 

Thank you in advance

Best answer by Werner_E

When a worksheet is evaluated it is read twice. In the first scan global assignments are collected, the second run deals with the rest.

So for global definitions the same rules apply as for normal ones. The sheet is read left to right, top down. So when the global(!) definition of h makes use of the globally(!) defined constant f, then f has to be defined in front or to the left of the definition of h.

 

BTW, it has proven a good advice over the years to use global definition with great care and as sparingly as possible.

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
November 9, 2023

When a worksheet is evaluated it is read twice. In the first scan global assignments are collected, the second run deals with the rest.

So for global definitions the same rules apply as for normal ones. The sheet is read left to right, top down. So when the global(!) definition of h makes use of the globally(!) defined constant f, then f has to be defined in front or to the left of the definition of h.

 

BTW, it has proven a good advice over the years to use global definition with great care and as sparingly as possible.