Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Include Files and where to declare them

Status
Not open for further replies.

Mickbw

Programmer
Jul 9, 2001
84
US
Hi,

I have three include files that I want to include with my project. My predecessor would declare them in a method where the include file would be accessed but I would like to declare it only once.

So I have a few questions:

1. Can I call all the include statements in the startup program and will they then be available throughout the operations of the program?

2. Can I have more than one include file declared at a time or should I combine all of my include files into one file?

3. Is there a command similar to the Set("Path") that will allow me to see what has been declared.

Any suggestions for a better way to handle this issue would be greatly appreciated.

Sincerely,

mickbw


 
HI

#INCLUDE is a preprocessor directive. This is not the same as memory variable repacing within the PRG or Form to substitute values when the variable name is used.

There is no memory usage. By using #INCLUDE, the code in the included file is added at the place of insertion.

SO there is no common #INCLUDE. YOu have to include it where ever you need.

But you can have the #INCLUDE myFile.H
as the first line of your main.prg or the event, so that all the replacements contained in the .H file is available for that ORG when the compiler processes the cell.

You can have more than one #INCLUDE file. YOu can use a valid path for the #INCLUDE myPath\myInclude.H

:)



____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Hi Ramani,

Does it matter where the include statement is located as long as it is done before the value from the .h file is needed? Should I be about to declare the in the following ways?


1. gcIncludeFile1 is the path and file name to the .h file declared as a public variable in the startup program and then do the #Include in the correct place in the method.

I have doing the #Include Statement in the following manners using this approach
a. #Include &gcIncludeFile1
b. #Include (gcIncludeFile1)
c. strInclude = "#Include ' " + gcIncludeFile1 + " ' "
&strInclude
d. strInclude = "#Include " + gcIncludeFile1
&strInclude

I have also tried placing the path & filename as a parameter named gcIncludeFile1 in a empty class I created to stay away from the extensive use of public variables.

Although I don't error out when running these statements I also don't have the values available for use in the method. Would I be just as well off to just declare the values in my empty variables class.

BTW, I am using VFP 8 SP 1.

Thanks for the quick reply,

Mick

 
#INCLUDE is interpreted at compile time, whereas &gcIncludeFile1 and (gcIncludeFile1) are substiuted at run time. So VFP thinks the name of the file is actually &gcIncludeFile1 or (gcIncludeFile1).
You need to put the full path in or maybe use a SET PATH TO ... statement so VFP knows where to find the files.

And also ... as long as it is done before the value from the .h file is needed? Correct.


-Dave S.-
[cheers]
Even more Fox stuff at:
 
Mickbw,

My usual approach is to establish the INCLUDE file within the development environment. You can do that either by storing the filename in the _INCLUDE system variable, or by setting it in Tools / Options / File Locations.

The disadvantage is that you must remember to make the same setting if you compile the app on another machine. The advantage is that you can keep the same Include files for all your apps (if that is what you want) without any extra effort.

Is there a command similar to the Set("Path") that will allow me to see what has been declared

No, because the Include file is only available at compile time. However, there is a #IFDEF compiler directive that you can use to determine if a particular constant has been #DEFINEd. But again, that only makes sense at compile time.

Mike


Mike Lewis
Edinburgh, Scotland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top