Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Variables for a report
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Title:
Variables for a report
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01011852
Message ID:
01011852
Views:
60
Just wondering if there isn't a safer/more elegant way to do this, now that we're all the way up to VFP 9...

I have a program that creates a couple dozen variables for a report. I declare the variables public, and then the report uses them when printing. So I start with something like:
PUBLIC iVolSvcCount, iVolSvcHrs, iVolOthCount, iVolOthHrs, iVolCountTotal
PUBLIC iVolActivity, iVolBoard, iVolFundraising, iVolLPPrep,  iVolOffice, iVolOther
PUBLIC iVolOutReach, iVolPlanning, iVolTraining, iVolTravel
PUBLIC iVolCtActivity, iVolCtBoard, iVolCtFundraising, iVolCtLPPrep,  iVolCtOffice, iVolCtOther
PUBLIC iVolCtOutReach, iVolCtPlanning, iVolCtTraining, iVolCtTravel
PUBLIC iVolWash, iVolOrange, iVolLamoille
And then I do a bunch of SQL queries, and dump the results into the variables, like:
SELECT voltime.person_id,SUM(voltime.HOURS)AS TOTAL FROM voltime,curVol;
	WHERE voltime.person_id=curVol.person_id;
	AND (voltime.DATE BETWEEN THISFORM.txtStartDate.dvalue AND THISFORM.txtEndDate.dvalue);
	AND voltime.person_id NOT IN (SELECT person.person_id FROM person WHERE staff);
	GROUP BY voltime.person_id;
	INTO CURSOR curTemp

SUM curTemp.TOTAL TO iVolOthHrs
..and then use iVolOthHrs in the report.

I'm sure that I should probably be clearing them all after running the program...OTOH there must be a way to refactor this mess?

The program code sits in two places, (at the moment...) in the Click event of a form which gathers a bunch of parameters for running the report, and in a series of form methods which do some auxiliary processing. Because I have to pass reference the variables within the report, and between the various locations of in the form...at the time it just seemed to make sense to keep the variables public. (I mean...it Just Works....right?) Also this whole thing is a holdover from about VFP 3.
-- Larry Keyes
Remember only You can prevent Gray Goo. Never release nanobot assembers without replication limiting code.
Next
Reply
Map
View

Click here to load this message in the networking platform