Author: Jose Constant
Posted: 1998-02-23 at 06:38:24
Prakash,
What you're asking seems out of reach with the present state of VFP
report writer. But we may try to tend to it. Here is what I am doing
right now.
Since VFP reports are not object oriented, I prepare one template report
per project.
In the BeforeOpenTables(), I create the report session environment:
goApp.oReportSessionEnvironment=CREATEOBJECT("cReportSessionEnvironment")
Its purpose is to SET all the fixed settings I'll need with all reports.
Code follows at the end of the message.
In the init(), I do the following:
LOCAL loDataEnvironment
*-- instantiate the Data Environment
*-- this will load all cursors needed for the report.
*-- Because the environment object is local, it will be
*-- destroyed when the object goes out of scope (when the
*-- init() method is exited). Since AutoCloseTables is set
*-- to .F., the cursors will stay open.
loDataEnvironment = CREATEOBJECT("<DataEnvironment>")
RETURN TYPE("loDataEnvironment") == "O"
and in the destroy I release the report session environment object
goApp.oReportSessionEnvironment = .NULL.:
You can make what you want in the init(). By example, if you use a
parameterized view, you could call a form to obtain the view parameters.
After trying out many things, I've found that the most convenient way is
to create a cursor with as many fields as the view parameters, and insert
a blank record. I pass the datasession as a parameter to the model form,
make sure that it shares the same datasession as the report, obtain the
view parameters, save them in the cursor. Once back in the Init() of the
report I can requery the view and proceed with the report.
**************************************************
*-- Class: creportsessionenvironment
(c:cdbk30common30libscenviron.vcx)
*-- ParentClass: cenvironment (c:cdbk30common30libscenviron.vcx)
*-- BaseClass: container
*
#INCLUDE "c:cdbk30common30includeframincl.h"
*
DEFINE CLASS creportsessionenvironment AS cenvironment
lsaveoldsettings = .F.
Name = "creportsessionenvironment"
PROCEDURE set
SET DELETED ON
SET TALK OFF
SET SAFETY ON
SET POINT TO ","
SET SEPARATOR TO "."
SET DATE FRENCH
SET CURRENCY TO "F"
SET CURRENCY RIGHT
SET CENTURY ON
ENDPROC
ENDDEFINE
*
*-- EndDefine: creportsessionenvironment
**************************************************
JosÃ
œ