Mike Lewis
Programmer
I've often thought it would be useful if VFP could prompt the programmer for information while it is running a build. For example, it could ask if you wanted a test or a production version of the application, and bring in the appropriate code depending on the reply.
The conventional way of doing this sort of conditional build would be something like this:
This is OK. But, whenever you do a build, you have to remember to open the file, check the #DEFINE, edit it if necessary, and save the file. It would be better if you could get VFP to prompt you for the setting during the build.
I thought I might be able to achieve that by using a projecthook, but I couldn't see any simple way of doing that.
Then I realised the #IF directive can take any expression as its operand, and that expression can include VFP functions, such as MESSAGEBOX(). So now I do this:
This achieves my goal perfectly.
You could extend the technique by using INPUTBOX() rather than MESSAGEBOX(). That would let you work with a variety of values, each of which could control the build in a more specific way.
Does anyone else here do anything like this? Or have you got some other method of varying the behaviour of a build?
In any case, I hope the above suggestion will be of interest.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips, training, consultancy
The conventional way of doing this sort of conditional build would be something like this:
Code:
#DEFINE COMPILE_TYPE "Test"
….
#IF COMPILE_TYPE == "Test"
* Test code goes here
#ELSE
* Production code goes here
#ENDIF
This is OK. But, whenever you do a build, you have to remember to open the file, check the #DEFINE, edit it if necessary, and save the file. It would be better if you could get VFP to prompt you for the setting during the build.
I thought I might be able to achieve that by using a projecthook, but I couldn't see any simple way of doing that.
Then I realised the #IF directive can take any expression as its operand, and that expression can include VFP functions, such as MESSAGEBOX(). So now I do this:
Code:
#IF MESSAGEBOX("Is this a test?", 4) = 6
* Test code goes here
#ELSE
* Production code goes here
#ENDIF
This achieves my goal perfectly.
You could extend the technique by using INPUTBOX() rather than MESSAGEBOX(). That would let you work with a variety of values, each of which could control the build in a more specific way.
Does anyone else here do anything like this? Or have you got some other method of varying the behaviour of a build?
In any case, I hope the above suggestion will be of interest.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips, training, consultancy