Page 1 of 1

UniScript and onScriptError Event from code

Posted: Sat 22 Mar 2014 11:12
by FCS
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

Re: UniScript and onScriptError Event from code

Posted: Mon 24 Mar 2014 13:24
by AlexP
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;

Re: UniScript and onScriptError Event from code

Posted: Mon 24 Mar 2014 15:28
by FCS
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

Re: UniScript and onScriptError Event from code

Posted: Tue 25 Mar 2014 10:03
by AlexP
This option is enabled by default. If you have disabled this option manually, in this case you need to use the {$H} directive.

Re: UniScript and onScriptError Event from code

Posted: Tue 25 Mar 2014 15:05
by FCS
Thanks

Regards
Michal

Re: UniScript and onScriptError Event from code

Posted: Wed 26 Mar 2014 09:06
by AlexP
You are welcome. Feel free to contact us if you have any further questions about UniDAC.