Determine if variable has been defined

jdgibson

New Member
In that case, why doesn't this work:

Code:
c = "hello".
DEFINE VARIABLE c AS CHARACTER   NO-UNDO.

At the point I'm trying to reference c, it hasn't been declared/defined. It obviously matters to the compiler where these definitions take place in the same block of code.

So if the compiler takes this into account, my earlier example (post #9) should work the way I want it to. Or at least, I should be able to find a way of knowing whether the variable has been defined at any given point.

Seems to me like yet another Progress inconsistency...

Of course it matters where a varibale is defined, it must be before it is used and definined in such a way thats its use is within scope. Your code example doesn't work because at the line c = "hello" the variable c isn't in the compilers symbol table because the compiler hasn't encountered it in the code. Compilers process code sequentially from start to finish and they all tend to work in pretty much the sameway. It is not an inconsistancy with progress as with any language where you are using static variables you cannot check for the existence of those variables ar run time.
 

praveen

New Member
if the problem is duplicate var names in include files, it would need to be dealt with at compile time before the problem happens

Code:
&if defined( globVar ) = 0 &then

    define var str  as char no-undo.
    define var i    as char no-undo.

    &glob globVar defined

&endif /* defined */
I have defined a GLOBAL-DEFINE variable in XXX.p.
I have a called an external procedure YYY.p in XXX.p .
Can I check the GLOBAL-DEFINE variable using
&IF DEFINED() in YYY.p ?
 
Top