Subject IB6 - FB 1.5.1 UDF Syntax Issue
Author eddiehodad
Hi All,

The UDF code below runs fine on IB6, but on FB 1.5.1, it generates:

conversion error from string "0"

I'm new to FB, so if someone can point out the errant line(s) and
suggest a fix, it'll be a great help. (also, please advise if there is
a more approprate group fior this post, thanks).

TIA,
Andrew

Here's the code:

function AnimalAge(dob, lact_date, test_date: PISC_QUAD):
integer;cdecl; export;
var
tm_dob, tm_lact, tm_test: tm;
dDob, dLact, dTest, dTo: TDateTime;
res : integer;
begin

isc_decode_date(dob, @tm_dob);
isc_decode_date(lact_date, @tm_lact);
isc_decode_date(test_date, @tm_test);

dDob := encodeDate(tm_dob.tm_year + cYearOffset,
tm_dob.tm_mon + 1,
tm_dob.tm_mday);
dLact := encodeDate(tm_Lact.tm_year + cYearOffset,
tm_Lact.tm_mon + 1,
tm_Lact.tm_mday);
dTest := encodeDate(tm_Test.tm_year + cYearOffset,
tm_Test.tm_mon + 1,
tm_Test.tm_mday);

if dDob < 0 then
result := 5
else begin
if dLact > 0 then
dTo := dLact
else if dTest > 0 then
dTo := dTest
else
dTo := now();

res := round((dTo - dDob)/365.25);
if res > 100 then res := 5;
result := res;

end;

end;