Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compiler Directives

9 views
Skip to first unread message

gotslack

unread,
Jun 12, 2008, 12:37:07 AM6/12/08
to
Hi. There is some way to set a compiler directive in runtime?

i.eg.

if SGDB = 'FIREBIRD' then
begin
{$define FIREBIRD};
end;

if SGDB = 'MSSQL' then
begin
{$define MSSQL};
end;

Thanks.

Jamie

unread,
Jun 12, 2008, 7:01:55 PM6/12/08
to
gotslack wrote:

No, You need to find out what DB is being used and flow your
code around it at run time or, stop using what ever it is that
most likely only works on one and not the other.


http://webpages.charter.net/jamie_5"

gotslack

unread,
Jun 13, 2008, 7:35:23 AM6/13/08
to
On Jun 12, 8:01 pm, Jamie

yeah, i know. i've already define some functions to make my SQL
Statements properly to a specific SGDB, like:

function SQLTopClause: String;
begin
{$ifdef FIREBIRD}
Result := 'First';
{$else if MSSQL}
Result := 'Top';
{$endif}
end;

just like that, ok?

but, i need to define the condition at runtime using a PARAMETER
defined at initialization process of the first unit of my project,
just as i've said on the fist message of this topic.

what should i do? use If Conditional Statements instead?

Jamie

unread,
Jun 13, 2008, 7:30:37 PM6/13/08
to
It's very simple.
Query the DB that is being used on start up!. and set a global
variable to indicate what DB is in use!.
I'm not much of a database programmer how ever, I do know that
functions and register keys exist to inform you of what engine
you're using..


http://webpages.charter.net/jamie_5"

BRoberts

unread,
Jun 13, 2008, 8:25:43 PM6/13/08
to

"gotslack" <eduv...@gmail.com> wrote in message
news:c4d626b6-bd75-4bd1...@b1g2000hsg.googlegroups.com...

unit dbSupporter;

interface

Type tdbType = (dbMSSQL, dbFireBird);

var dbType : tdbType = dbMSSQL;

Initialization

If CompareText (ParamStr (1), 'FIREBIRD') = 0
then dbType := dbFireBird;

end.

// some unit

Uses . . ., dbSupporter, . . .;

Const cTopClauses : array [tdbType] of string = ('Top', 'First');

function sqlTopClause : string;

begin
result := cTopClauses [dbType];
end;

0 new messages