Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread External Modules and functions
Fri, Feb 8 2008 11:17 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

Prepare thyself for a deluge of questions - I'm starting my attempts to write a function in an external module. I thought I'd start with something simple (see below).

In the dll the function is SpacelessCompare(const FldStr, CompStr: string): boolean; Initially I added it to EDBManager

CREATE FUNCTION "SpaceLess" (IN "Fld" VARCHAR COLLATE ANSI, IN "Against" VARCHAR COLLATE ANSI)
RETURNS BOOLEAN
EXTERNAL NAME "nlhFunctions"

and tried

select * from companies where Spaceless(_Name,'A F N Ltd') - no rows returned, tried adding =True and =False to the end and still no result. Then thought "hmm I don't know what name gets passed so I'll set the name to the same one as in the dll and trying

select * from companies where SpacelessCompare(_Name,'A F N Ltd') I get

ElevateDB Error #202 An error occurred with the module nlhFunctions (Access violation at address 01A8A54F in module 'nlhFunctions.dll'. Read of address 00000030)

Off now to add debugging code to my dll

Roy Lambert

unit nlhFuncs;

interface

uses SysUtils, Classes, DB, edbextmodule;

type
TEDBExternalModule1 = class(TEDBExternalModule)
 procedure EDBExternalModuleRoutine(const RoutineName: string);
private
   { Private declarations }
public
   { Public declarations }
end;

var
EDBExternalModule1: TEDBExternalModule1;

implementation

{$R *.dfm}

function SpacelessCompare(const FldStr, CompStr: string): boolean;
begin
Result := StringReplace(FldStr, ' ', '', [rfReplaceAll]) = StringReplace(CompStr, ' ', '', [rfReplaceAll]);
end;

procedure TEDBExternalModule1.EDBExternalModuleRoutine(
const RoutineName: string);
begin
if LowerCase(RoutineName) = 'spacelesscompare' then Params.FindParam('Result').AsBoolean := SpacelessCompare(Params.FindParam('Phone').AsString, Params.FindParam('TestAgainst').AsString);
end;

end.
Fri, Feb 8 2008 11:52 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

And just for a change - its me <vbg>. The function name has to match, and you need to get the parameter names right - makes sense.

Roy Lambert
Fri, Feb 8 2008 12:55 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< And just for a change - its me <vbg>. The function name has to match, and
you need to get the parameter names right - makes sense. >>

So, the AV was in your code ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Fri, Feb 8 2008 1:02 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


Yup, caused by trying to find a parameter that doesn't exist I think. eg  Params.FindParam('Phone').AsString when I'm passing 'FldCmp'. I'm assuming this because the showmessages I added didn't enter the function itself.

Roy Lambert
Image