Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Compiler directive only for dev time
Message
De
17/09/2014 11:26:52
Mike Yearwood
Toronto, Ontario, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01607627
Message ID:
01607736
Vues:
76
>>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?

At design time, we can run a form standalone. If we first did a clear all, we would need to re-establish the app object etc. That would never, ever be needed in the exe. So I'm trying to exclude it from compilation.


>
>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.

Yes. Experienced that before!

>
>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.

I think I'd rather avoid such recompilation.

>
>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.

You are a genius! Of course! I should have thought of that. If the empty procedure "idesetup" is in the main.prg, it is immediately visible throughout all the called code without requiring a SET PROCEDURE TO. If the form class has a call to DO idesetup, and that is in the path on the dev machines, it will fire. So the dev is slightly slower, but the exe is unaffected. Brilliant!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform