Creating a Global Variable Program
Hi There,
I am using D2009 & RB11.03.
I am creating a designer application to allow us to create database
stored RAP base report templates. To simplify the development of each
report I want to when creating a new report create some report
components using Delphi code and set up the RAP code automatically to
objects which are required in every report.
These components consist of some TppLabels, TppSystemVariables, and
TppVariables. One of the TppVariables require an object to be declared
in the global variables program module, of which an instance is created
in the global OnCreate and freed in the global OnDestroy.
My code successfully sets up the RAP for the onCreate and onDestroy.
Having some difficulty with the global variables declaration though.
I've not found any examples of this one so I am guessing for the moment
without success. I have tried:
lCodeModule.GlobalVarProgram := TraVarProgram.Create;
prgGlobalVar := lCodeModule.GlobalVarProgram;
prgGlobalVar.GenerateProgramShell;
prgGlobalVar.BodyText := 'var '#13#10' PBSCompanySettings :
TPBSCompanySettings;';
This however when the report loads tells me there is an error in the
first line with: Error: , Line 0: Missing the program name.
What am I missing?
Thanks,
Kevin
I am using D2009 & RB11.03.
I am creating a designer application to allow us to create database
stored RAP base report templates. To simplify the development of each
report I want to when creating a new report create some report
components using Delphi code and set up the RAP code automatically to
objects which are required in every report.
These components consist of some TppLabels, TppSystemVariables, and
TppVariables. One of the TppVariables require an object to be declared
in the global variables program module, of which an instance is created
in the global OnCreate and freed in the global OnDestroy.
My code successfully sets up the RAP for the onCreate and onDestroy.
Having some difficulty with the global variables declaration though.
I've not found any examples of this one so I am guessing for the moment
without success. I have tried:
lCodeModule.GlobalVarProgram := TraVarProgram.Create;
prgGlobalVar := lCodeModule.GlobalVarProgram;
prgGlobalVar.GenerateProgramShell;
prgGlobalVar.BodyText := 'var '#13#10' PBSCompanySettings :
TPBSCompanySettings;';
This however when the report loads tells me there is an error in the
first line with: Error: , Line 0: Missing the program name.
What am I missing?
Thanks,
Kevin
This discussion has been closed.
Comments
More on this, I said I was successful with adding RAP code for the
global onCreate and onDestroy. Once I previewed the report I realised I
wasn't. It threw me an exception about not being able to hook up the
event. When I went back to the 'Calc' tab I discoved the OnCreate and
onDestroy was clear. The code I have attempted to use:
lCodeModule.GlobalCreateProgram :=
CodeModule.CreateEventHandler(lCodeModule,'OnCreate');
prgGlobalCreate := lCodeModule.GlobalCreateProgram;
with prgGlobalCreate.SourceLines do
begin
Clear;
Add('procedure GlobalOnCreate;');
add('begin');
Add(' PBSCompanySettings :=
TPBSCompanySettings.Create(Report.Owner);');
add('end;');
end;
So how do I do this?
Thanks Again,
Kevin.
Take a look at the following article on creating RAP globals in Delphi code.
http://www.digital-metaphors.com/rbWiki/RAP/Fundamentals/How_To...Create_RAP_Globals_in_Code
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I missed that article completely.
Thanks,
Kevin.