Exception Handling in RAP
In my app, many of my built-in reports use RAP. End Users may not have
access to RAP as I remove that from some editions of my software.
However, when they modify/save reports as templates to their database,
and delete a RB component that has RAP code attached they get an
exception. I could tell them to not delete any components, just make
them invisible, but that is ugly. Is there any other way to handle
this, such as excetption handling in RAP so that if a component is
missing that has RAP code attached, it does not affect their report
template?
--
David Farrell-Garcia
Whidbey Island Software, LLC
access to RAP as I remove that from some editions of my software.
However, when they modify/save reports as templates to their database,
and delete a RB component that has RAP code attached they get an
exception. I could tell them to not delete any components, just make
them invisible, but that is ugly. Is there any other way to handle
this, such as excetption handling in RAP so that if a component is
missing that has RAP code attached, it does not affect their report
template?
--
David Farrell-Garcia
Whidbey Island Software, LLC
This discussion has been closed.
Comments
for example:
if assigned(ppLabel1) then
.........
--
David Farrell-Garcia
Whidbey Island Software, LLC
If the user deletes a Label, then any RAP event-handlers associated with the
Label's events will also be deleted. However, if you have code in say, the
Band.BeforePrint event, that references the Label, then that will cause a
compile error.
One option would be to add a custom RAP function that can check whether a
component with exists. Then call the function from your RAP code, like
this....
if ComponentExists(Report, 'Label1') then
begin
end;
In Delphi code you could implement that function like this..
(psuedo code)
uses
ppClass, raCodMod;
function ComponentExists(aReport: TppCustomReport; aUserName: String):
Boolean;
var
lCodeModule: TraCodeModule;
begin
lCodeModule := raGetCodeModule(aReport);
lComponent := lCodeModule.FindUserObject(aUserName);
Result := lComponent <> nil;
end;
Try to implement the above function in Delphi code and call it from a Delphi
event-handler. Once you have that working, convert it to a RAP pass-thru
function that is registred with the RAP CodeToolbox.
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
"David Farrell-Garcia"
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
I have never used RAP passthrough functions. Is there a good example
of using this feature and regisetring it with the RAP CodeToolbox?
--
David Farrell-Garcia
Whidbey Island Software, LLC
One of the best features of RAP is how easy and powerful it is to extend it
with custom functions and RTTI.
For more details, check out the 'Adding Functions to RAP' tutorial in the RB
Developers Guide and the RBuilder\Demos\RAP demos.
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com