How to check for RAP compilation errors on saving the template in designer?
Hallo,
I would like to check the template being saved in the designer for RAP
compilation errors just before saving it.
My idea is:
A stupid customer has deleted a visual component from the template and is
saving the template without compiling it or going in the preview.
The component deleted is involved in a RAP routine within the report. The
template could be saved with no errors. Weeks later the same customer starts
the report and gets an error "XXX could not be compiled..." and has no clue.
Can I force the RAP compilation or a preview just before saving the report
and prevent the report from being saved if there are RAP compilation errors?
I am deploying the method TppDesigner.OnCustomSaveDoc for saving the
templates.
Thanks a lot!
Kind regards
Leo Kaploun
I would like to check the template being saved in the designer for RAP
compilation errors just before saving it.
My idea is:
A stupid customer has deleted a visual component from the template and is
saving the template without compiling it or going in the preview.
The component deleted is involved in a RAP routine within the report. The
template could be saved with no errors. Weeks later the same customer starts
the report and gets an error "XXX could not be compiled..." and has no clue.
Can I force the RAP compilation or a preview just before saving the report
and prevent the report from being saved if there are RAP compilation errors?
I am deploying the method TppDesigner.OnCustomSaveDoc for saving the
templates.
Thanks a lot!
Kind regards
Leo Kaploun
This discussion has been closed.
Comments
You can use the TraCodeModule.BuildAll routine to compile all the code in
the template and show an exception for your users at the time you save the
template.
uses
raCodMod;
TraCodeModule(Report.CodeModule).BuildAll(True);
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Is there anyw ay to add excetion handling or test for assignment in the
RAP routine so that the user could delete a component referenced in a
RAP routine without causing a problem with their template. We don't
make RAP availalbe in all versions of our software, but use it
ourselves in the built-in reports which they can modify and save as
templates to the database.
--
David Farrell-Garcia
Whidbey Island Software, LLC
I save the templates to the database on the Designer.onclose event, I
check the dataset for changecount and this works perfectly, but when I
add the following code to the CustomSaveDoc event a new report template
does not save even if no exception occurs. The changecount shows zero.
If I simply remove the handler below, all goes well. Is there
something else I need to add to this handler so that the change go to
the template table when no exceptions occur?
procedure TBaseReportForm.ppDesignerCustomSaveDoc(Sender: TObject);
const
msg = 'You may have deleted a component that has underlying code'+
' attached. Rather then delete components you should set the'+
' VISIBLE property to FALSE and move them out of your workspace.'+
' Try to Undo your changes or start again';
begin
try
TraCodeModule(ppReport.CodeModule).BuildAll(True);
except
ShowTaskMessage(tdINFO, 'Error Saving Report', msg);
SysUtils.Abort;
end;
end;
RB 10.06 / Delphi7
--
David Farrell-Garcia
Whidbey Island Software, LLC
Once you implement the OnCustomSaveDoc event, you must then provide the
logic which will save the report. ReportBuilder will no longer save the
report for you. Take a look at the TppTemplate class in the ppTmplat.pas
file for how a report is saved in RB.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
"David Farrell-Garcia"
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Ok, I will do that. Thanks. Is it a question of just settting the
Template properties of the report component again? does the
OnCustomSavedoc set those to nil?
--
David Farrell-Garcia
Whidbey Island Software, LLC
Ok, I took a quick look at the code. That llooks like the SaveToSource
method has the stuff I need, however it looks like a bit of work to
implment. I was hoping for something like a protected boolean var that
would just exit the procedure but I see that is not possible since you
have other code that relies on simply checking if the OnCustomSaveDoc
method has been assigned.
Is there an easier way to prevent an end user from deleting a component
that has RAP code attached. A hidden (from end user) CANNOTDELETE
property of all visible components would be nice.
--
David Farrell-Garcia
Whidbey Island Software, LLC