clipper

Visual Objects - Retrieving string DEFINE dynamically - #ifdef is returning false


This is regarding the Visual Objects programming language based upon Clipper.

I'm trying to load the values of a few DEFINE constants, I've tried using #ifdef to determine if they exist however it doesn't seem to work with strings, just numbers or logics, e.g.:

DEFINE TEST_LOGIC := True
DEFINE TEST_NUM := 1
DEFINE TEST_STRING := "HELLO"

#IFDEF TEST_LOGIC
  // Runs
#ENDIF
#IFDEF TEST_NUM
  // Runs
#ENDIF
#IFDEF TEST_STRING
  // Does not run
#ENDIF

Is there some other way of determining whether they exist and returning their values? I've tried VarGet() and MemVarGet() but they can't see the constant and cause a runtime error, and #ifdef cannot accept a method call like !Empty(TEST_STRING) (will not compile), using a direct comparison like #ifdef TEST_STRING > " " also doesn't work (compiles and runs but the code block does not execute).


Solution

  • There doesn't seem to be a way to do this using DEFINE statements containing strings, however if it's changed to a GLOBAL declaration then the #ifdef statement will work as expected.