Subject | RE: [IBO] Questions about TIB_Script |
---|---|
Author | Helen Borrie |
Post date | 2006-07-14T03:49:56Z |
At 12:48 PM 14/07/2006, Michael Spence wrote:
appropriate "On..." event handler. (You'll find the templates for
the event handlers on the Events tab of the Object Inspector,
standard Delphi stuff!) Put the resolutions for all your macros in
this procedure.
procedure TConverterForm.IB_Script1MacroSubstitute(Sender: TComponent;
const ATextBlock: String; var ATextResult: String);
begin
if ATextBlock = 'database' then
ATextResult := QuotedStr(newDB.Text)
else
if ATextBlock = 'auser' then .....
end;
I think you will find you'll get an exception from the server because
of the illegal use of double quotes in the database path
argument. Double quotes have one and only one use in SQL, as
optional delimiters for database objects. Quotes for strings in SQL
are apostrophes. Besides the above (e.g. if you are using CPPB) you do it as:
begin
ATextResult := #39+newDB.Text+#39;
end;
understanding of the substitute logic and the way Delphi event
handlers work. There are some examples of actual use in the help
document for the IBO Replication components.
BTW, make sure you put in some kind of checking to ensure that the
path exists and will be a valid path for the OS that the database is
being created on. For Windows, there's a filesystem function, sthg
like PathExists. For Linux, you'd need to parse it out yourself.
Helen
>procedure TConverterForm.sysCreateScriptMacroSubstitute(Sender: TComponent;Don't call the "Sys..." procedures to write event handlers, use the
> const ATextBlock: string; var ATextResult: string);
>begin
> ATextResult := '"' + newDB.Text + '"';
>end;
>
>Here is the SQL statement from the TIB_Script object:
>
>CREATE DATABASE <<database>>
> USER 'SYSDBA' PASSWORD 'masterkey';
>
><< and >> are set as MacroBegin and MacroEnd.
>
>I tried
>
>CREATE DATABASE "<<database>>"
> USER 'SYSDBA' PASSWORD 'masterkey';
>
>so I wouldn't have to provide the quotes, but then the parser didn't
>see the macro.
appropriate "On..." event handler. (You'll find the templates for
the event handlers on the Events tab of the Object Inspector,
standard Delphi stuff!) Put the resolutions for all your macros in
this procedure.
procedure TConverterForm.IB_Script1MacroSubstitute(Sender: TComponent;
const ATextBlock: String; var ATextResult: String);
begin
if ATextBlock = 'database' then
ATextResult := QuotedStr(newDB.Text)
else
if ATextBlock = 'auser' then .....
end;
I think you will find you'll get an exception from the server because
of the illegal use of double quotes in the database path
argument. Double quotes have one and only one use in SQL, as
optional delimiters for database objects. Quotes for strings in SQL
are apostrophes. Besides the above (e.g. if you are using CPPB) you do it as:
begin
ATextResult := #39+newDB.Text+#39;
end;
>Is there some documentation on how the macro substitution actually works?Sort of. But there's not much to it, as long as you have a basic
understanding of the substitute logic and the way Delphi event
handlers work. There are some examples of actual use in the help
document for the IBO Replication components.
BTW, make sure you put in some kind of checking to ensure that the
path exists and will be a valid path for the OS that the database is
being created on. For Windows, there's a filesystem function, sthg
like PathExists. For Linux, you'd need to parse it out yourself.
Helen