UniScript and onScriptError Event from code

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
FCS
Posts: 176
Joined: Sat 23 Feb 2013 18:46

UniScript and onScriptError Event from code

Post by FCS » Sat 22 Mar 2014 11:12

Hello,

How to assign onScriptError event when UniScript is created from the code ?

For example:
UScript:=TUniScript.Create(self);
UScript.Connection:=UniConnection1;
UScript.onScriptError := ????

Regards
Michal

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: UniScript and onScriptError Event from code

Post by AlexP » Mon 24 Mar 2014 13:24

Hello,

You need to declare and implement the OnError method in the following way:

Code: Select all

TForm1 = class(TForm)
UniConnection1: TUniConnection;
...
public
procedure UniScriptonError(Sender: TObject; E: Exception; SQL: string; var Action: TErrorAction);

.......
procedure TForm4.UniScriptonError(Sender: TObject; E: Exception; SQL: string; var Action: TErrorAction);
begin
//............................
end;

var
UniScript: TUniScript;
begin
UniScript := TUniScript.Create(nil);
UniScript.Connection := UniConnection1;
UniScript.OnError := UniScriptonError;

FCS
Posts: 176
Joined: Sat 23 Feb 2013 18:46

Re: UniScript and onScriptError Event from code

Post by FCS » Mon 24 Mar 2014 15:28

Hello,

Thanks.
I tried do it like you wrote. The compiler was showing, that I had a bug in parameters at line
UniScript.OnError := UniScriptonError;

I had to enable huge strings for these procedures like bellow:

public
{$H+}
procedure UniScriptonError(Sender: TObject; E: Exception; SQL: string; var Action: TErrorAction);
{$H-}
.......

{$H+}
procedure TForm4.UniScriptonError(Sender: TObject; E: Exception; SQL: string; var Action: TErrorAction);
begin
//............................
end;
{$H-}

Regards
Michal

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: UniScript and onScriptError Event from code

Post by AlexP » Tue 25 Mar 2014 10:03

This option is enabled by default. If you have disabled this option manually, in this case you need to use the {$H} directive.

FCS
Posts: 176
Joined: Sat 23 Feb 2013 18:46

Re: UniScript and onScriptError Event from code

Post by FCS » Tue 25 Mar 2014 15:05

Thanks

Regards
Michal

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: UniScript and onScriptError Event from code

Post by AlexP » Wed 26 Mar 2014 09:06

You are welcome. Feel free to contact us if you have any further questions about UniDAC.

Post Reply