Search code examples
constantswindev

Windev constant for test mode


We have some constants inside our project. One is for the URL of a server. Is it possible to make the constant being different when in test mode?

Something like:

IF InTestMode() THEN
    CONSTANT URL = "http://test.com"
ELSE
    CONSTANT URL = "http://prod.com"
END

Thanks.


Solution

  • Constant are in fact supposed to be constants.

    What you are searching for is a global variable defined at project level. You can initialize your variable the way you want, using or not your constant with something like that :

    CONSTANT
        URL_PROD = "http://prod.com"
        URL_TEST = "http://test.com"
    END
    
    gsURL is a string = InTestMode() ? URL_TEST ELSE URL_PROD