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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

#DEFINE not being recognized in macro 1

Status
Not open for further replies.

mkrausnick

Programmer
Apr 2, 2002
766
US
This is a re-posting of a previous thread that disappeared before I could view responses.

I created the following specialized report printing function in a (VFP 9) PRG to be able to generate PDF files, handling the various Acrobat versions:
Code:
#INCLUDE DEFINES.FH
FUNCTION PrintPDFReport(p_ReportString,p_FileName)
.
. some setup code
.
IF g_AcrobatVersion > 5
	REPORT FORM &p_ReportString. TO FILE (p_FileName+".PS")
ELSE 
	REPORT FORM &p_ReportString. NOEJECT NOCONSOLE TO PRINTER
ENDIF 
.
. more code
.
As you can see, I pass the report name and scope as a parameter and then reference it via macro substitution.

If the parameter refers to a #DEFINE defined in DEFINES.FH, the program gets a "variable not found" error.

For example, I passed p_ReportString as "reports\statusletter FOR prov_id = ACMC_ID" where ACMC_ID is defined in DEFINES.FH. The calling program errored with "Variable ACMC_ID not found".

Is there a trick to this, or does this not work in VFP?

Mike Krausnick
Dublin, California
 
I saw the answer to your question earlier today. Basically, the #DEFINES get evaluated when the program is compiled and - at that point in time - the contents of the parameters are unknown.

Regards,
Jim
 
I think I said that you should be setting p_ReportString as:

p_ReportString = "reports\statusletter FOR prov_id = " + ACMC_ID

Your code is asking Fox to look for records where prov_id = ACMC_ID so Fox is looking for the variable named ACMC_ID.

Geoff Franklin
 
Geoff, that did the trick. I live to code another day.

Thanks to you both!

Mike Krausnick
Dublin, California
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top