Subject Re: [IBDI] UDF Questions
Author Robert F. Tulloch
Hi:

It is not the sp failing. I set up a table test with field cleartest then:

Update Test
set Cleartest = ClearIbLog() and the returned value was False. Could there be any
problem with relative path inside the function? It is in Interbase\UDF and the path in
the function is ..\interbase.log. This works fine when executing exported function
with test program. I don't see where IB could efect that.


> Don't know what IB is expecting but I assume it is the SP failing. Any thoughts
> appreciated.
>
> Best
> regards
>
> --------------------------------------------------------------------------
> /* External Function declarations */
>
> DECLARE EXTERNAL FUNCTION CLEARIBLOG
> RETURNS CSTRING(80) CHARACTER SET NONE FREE_IT
> ENTRY_POINT 'fn_ClearIbLog' MODULE_NAME 'ltudf';
>
> ---------------------------------------------------------------------------
>
> set term ## ;
> create procedure ClearLog
> Returns(Result varchar(80))
> as
> begin
> Result = ClearIBLog();
> exit;
> end ##
> set term ; ##
>
> ----------------------------------------------------------------------------
> ..dll header
>
> extern "C" __declspec(dllexport) char* __stdcall fn_ClearIbLog();
>
> ----------------------------------------------------------------------------
> ..dll cpp
> //---------------------------------------------------------------------------
> char *buf;
> char* __stdcall fn_ClearIbLog()
> {
> char *s;
> TStringList *IBLog = new TStringList();
> try
> {
> IBLog->LoadFromFile("..\\interbase.log");
> IBLog->Clear();
> IBLog->Add(" ");
> String NewHeader = "LTDMS Interbase.Log cleared on " + DateToStr(Date());
> IBLog->Add(NewHeader);
> IBLog->Add("------------------------------------------------------------");
> IBLog->SaveToFile("..\\interbase.log");
> delete IBLog;
> s = "True";
> }
> catch(...)
> {
> delete IBLog;
> s = "False";
> }
> char *p;
> buf = (char*)malloc(strlen (s) + 1);
> p = buf;
> while (*s)
> *p++ = *s++;
> *p = '\0';
>
> return buf;
> }
>
> Community email addresses:
> Post message: IBDI@onelist.com
> Subscribe: IBDI-subscribe@onelist.com
> Unsubscribe: IBDI-unsubscribe@onelist.com
> List owner: IBDI-owner@onelist.com
>
> Shortcut URL to this page:
> http://www.onelist.com/community/IBDI