Subject | Re: UDF assistance |
---|---|
Author | Adam |
Post date | 2008-12-01T23:39:07Z |
--- In firebird-support@yahoogroups.com, "Ivan Prenosil"
<Ivan.Prenosil@...> wrote:
Do you mean something like:
....
function FB_AddMins(var DT: ISC_TIMESTAMP; var Minutes: Integer):
PISC_TIMESTAMP; cdecl;
var
DTConverted: TDateTime;
begin
OutputDebugString('FB_AddMins Start');
DTConverted := TimeStampToDateTime(DT);
DTConverted := DTConverted + Minutes/1440;
DT := DateTimeToTimeStamp(DTConverted);
Result := ib_util_malloc(SizeOf(DT));
Result.timestamp_date := DT.timestamp_date;
Result.timestamp_time := DT.timestamp_time;
OutputDebugString('FB_AddMins End');
end;
...
In the 5 minutes of testing I have had a chance to do so far, it seems
to work (ie has not crashed).
Also, is there any documentation that you are aware of for writing
UDFs in Firebird using Delphi? I have been working so far with a
number of FAQs, short guides and example code.
Adam
<Ivan.Prenosil@...> wrote:
>'ib_util.dll';
> > Declaration:
> > ============
> >
> > DECLARE EXTERNAL FUNCTION FB_ADDMINS
> > TIMESTAMP,INTEGER
> > RETURNS TIMESTAMP FREE_IT
> > ENTRY_POINT 'FB_AddMins' MODULE_NAME 'MyUDF';
> >
>
> > UDF Code (Delphi 7):
> > ==================
> > {Export Functions}
> >
> > function FB_AddMins(var DT: ISC_TIMESTAMP; var Minutes: Integer):
> > PISC_TIMESTAMP; cdecl;
> > var
> > DTConverted: TDateTime;
> > begin
> > OutputDebugString('FB_AddMins Start');
> > DTConverted := TimeStampToDateTime(DT);
> > DTConverted := DTConverted + Minutes/1440;
> > DT := DateTimeToTimeStamp(DTConverted);
> > Result := @DT;
> > OutputDebugString('FB_AddMins End');
> > end;
>
>
> Memory for the result must be allocated using:
>
> function ib_util_malloc(size: LongWord): Pointer; external
>Hello Ivan,
Do you mean something like:
....
function FB_AddMins(var DT: ISC_TIMESTAMP; var Minutes: Integer):
PISC_TIMESTAMP; cdecl;
var
DTConverted: TDateTime;
begin
OutputDebugString('FB_AddMins Start');
DTConverted := TimeStampToDateTime(DT);
DTConverted := DTConverted + Minutes/1440;
DT := DateTimeToTimeStamp(DTConverted);
Result := ib_util_malloc(SizeOf(DT));
Result.timestamp_date := DT.timestamp_date;
Result.timestamp_time := DT.timestamp_time;
OutputDebugString('FB_AddMins End');
end;
...
In the 5 minutes of testing I have had a chance to do so far, it seems
to work (ie has not crashed).
Also, is there any documentation that you are aware of for writing
UDFs in Firebird using Delphi? I have been working so far with a
number of FAQs, short guides and example code.
Adam