sybasepreprocessorpowerbuilder

Powerbuilder preprocessor directive and DEBUG not working


I'm having some buggy behavior with DEBUG and precompiler directives.

I have a PowerBuilder application. In the production environment it logs in using a certificate, but in Dev, to make things easier on myself I want to login with username and password. I added this bit of code:

#if defined DEBUG then
   MessageBox("Info","Running in DEBUG mode, certificates disabled!")
   ibool_certlogin = FALSE
#else
   ibool_certlogin = TRUE
#end if

This seems to only work sometimes. When I first load the project, and run it it fails. Meaning, even though I'm in the IDE and DEBUG should be defined, the message box still does not display, and the certificates are still enabled.

I can however correct the behavior with a somewhat arbitrary change. Specifically, if I open the module this code is in, and then arbitrarily type a space, and then save. Then I run the project the message box correctly displays and the certificates are correctly disabled. It continues to function correctly until I close PowerBuidler IDE and reopen it.

Has anyone experience this or know a solution?


Solution

  • I believe that you need to rebuild the project if you make a a change in a directive, a simple run is not enough.

    A simpler solution if you need a specific behaviour when running from the IDE is :

    IF handle(getapplication()) = 0 THEN
        // running from the IDE
        ...
    ELSE
        // running from EXECUTABLE
    END IF