Quote from: Anderson P. on July 05, 2017, 04:19:46 PM
Sebastien, thanks for your reply.
We are aware that this "globals" approach is kind of depreciated, the problem is that all of our programs use a default global set of functions and variables, and seems like we can't have a "globals" and a "import fgl" at the same file, is one or other. Is that right?
So we would have to replace the globals in all our programs with the import fgl, and to archive this will be necessary to change all the global set functions usage to include the module name.
That's why we still use globals and can't use import fgl. I don't know if there is some workaround to use globals and import fgl at the same file.
with regard to your comment "and to archive (I think you meant achieve) this will be necessary to change all the global set functions usage to include the module name"
if the function name / variable name was unique, you would not have to "change all the global set functions usage to include the module name"
#!foo.4gl
PUBLIC DEFINE x INTEGER
PUBLIC CONSTANT ZERO=0
FUNCTION bar()
DISPLAY "bar"
END FUNCTION
#!main.4gl
IMPORT FGL foo
MAIN
CALL bar()
LET x = 0
DISPLAY x
DISPLAY ZERO
END MAIN
>fglcomp foo.4gl
>fglcomp main.4gl
>fglrun main.42m
bar
0
0
Whilst it would be preferable and I'd argue a good standard to adhere to prefix with the module name e.g. in the above code I would rather see DISPLAY
foo.bar() LET foo.x = 0 DISPLAY
foo.ZERO etc, it isn't necessary if the imported function/variable/constant name is unique.
With "gc_letras_com_acento" I'm guessing gc stands for global constant, so it should be unique enough that your code change is GLOBALS "globals_file" TO IMPORT FGL globals_file, and changing CONSTANT gc_letras_com_acento ... to PUBLIC CONSTANT gc_letras_com_acento ..., and you should not have to change all references of gc_letras_com_acento to globals_file.gc_letras_com_acento, if that is what you are afraid of.
Also with your original question ...
My question is, why don't Genero simply assumes this new constant value, instead of presenting the error? It has already loaded the constant value for doing the compare. We are trying to understand why it gives this error instead of assuming the new value.
... to help understand, do something like od -c program-name.42r or strings program-name.42r, and fglrun -r module-name.42m (you might need to create a small example to make it all easier to read and interpret). A common misconception is that a .42r is like a binary executable, it is not. All the computational logic is inside each .42m. The fglrun -r shows some of this logic, you'll see it pushing constants onto a stack, pointers to the constant values etc
Number of constants: 1
0 INTEGER `100'
Global variables:
HUNDRED 0 INTEGER
...
pushGlb HUNDRED
This is repeated in each of the .42m. So if the runner detects where the global constant in one .42m is different than the value of the same global constant in another .42m, then the decision is made to stop rather than assuming one value is more correct than the other.
Hope that helps
Reuben