Subject Re: [IBO] TIB_Script: Working with Macros
Author Helen Borrie
At 02:45 PM 13-10-02 +0200, you wrote:
> > Possibly you are misunderstanding the usage of macros. They are typically
> > for substituting repeating strings or blocks of statements, for example in
> > a replication or fuzzy-text application setup script, and the MacroBegin
> > and MacroEnd characters need to be set up explicitly in your script where
> > the macro is wanted, e.g. you might use '$$' for both MacroBegin and
> > MacroEnd and, in your script, include the placeholder '$$MACRO_1$$'. The
> > OnMacroSubstitute event is where you handle the substitution. For a
>simple
> > example,
> >
> > ...
> > if ATextBlock = 'MACRO_1' then
> > ATextResult := 'CREATE TRIGGER';
> >
> > What task is your script trying to do with macros? What does the macro
> > placeholder in your script look like? What is your OnMacroSubstitute
>code?
> >
> > Helen
>
>Thanks for your answer(s).
>
>I think I didn't misunderstand the usage of macros. I just want to replace a
>macro string with a meaningful content:
>
>I have set IB_Script.MacroBegin := ### and IB_Script.MacroEnd := $$$
>
>This is my statement in the script:
>
>connect database ###DBPath$$$ user "SYSDBA" password "masterkey";
>
>This code should be executed in OnMacroSubstitute:
>
> if ATextBlock = 'DBPath' then
> ATextResult := format('"%s"',[MyRegistry.DBPath]);
>
>But this event does not fire. (beside the problem with double quotes and the
>keyword database), but this is handled in the other previous posting).
>
>In the meanwhile I catch the event OnStatement and replace the macro by
>myself.
>
>Any hints why OnMacroSubstitute does not fire?

Only a hint: I am flat-out and don't have time to test your example
myself, but since the OnStatement event *does* fire, my guess is that
'connect database' is throwing a parser error before the parser even
reaches the macro. What does the SQL Monitor reveal?

Helen