Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compiler directive only for dev time
Message
 
To
16/09/2014 13:12:08
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01607627
Message ID:
01607729
Views:
84
Likes (1)
>I am trying to execute a piece of code only at design time, never at runtime. I thought I could do a compiler directive.

What's your intention with that?

The preprocessor has been tightened up in VFP 6. Until VFP 5 you could check for object references and variables. Since VFP 6 variable references are always undefined. Your line should either cause an error (if used in a PRG) or be silently ignored (when used in an include file, or a nested include file).

Keep in mind that such a check would not be treated as a dependency by Visual FoxPro. If you use something like a file and delete the file this will not cause VFP to recompile the source code. Recompile all in the project manager will not recompile FXP files if no dependency has changed, so you would need to delete the flag file, delete all FXP files and then rebuild the project with recompile all to make these changes stick.

If you need something like the debug/release builds in Visual Studio, the easiest way is to use an include file (eg. build.h) that defines the build mode and then change the content of the file before you create the EXE and back afterwards. This changes the timestamp of the include file which is a dependency and will trigger a recompilation of all dependent source files in VFP when you rebuild the project.

If your intention is to hook into the form designer, you might use a property with a property expression that uses a function that is available as a PRG in the current directory and as an empty function in a procedure file. This would call the PRG in the designer, but the function in the procedure at runtime. Make sure the PRG is not added to the project and the procedure file activated with SET PROCEDURE TO before you call the form.
--
Christof
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform