Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with DLLs

Status
Not open for further replies.

lloydie2

Programmer
Apr 21, 2003
75
GB
I am writing my first appalication and I need A DLL, But I dont seem to be gettin any joy gettin it to work. I have a problem with a var not being declared, but I thought that becuase it was a part of the DLL function, I did'nt do that.Can you have a look at it? How do you create the actual DLL? If I try to run it, It exspects statements.

DLL
------------------------------------------------------
library collexconv;

uses
ShareMem,
SysUtils,
Classes;

{$R *.res}

Function VarCreate (S: String): String stdcall;
begin
ExtVar := copy(S,8,4);
InOut := copy(S,13,3);
Line := copy(S,12,3);
CallDate := copy(S,21,2);
CallMonth := copy(S,24,2);
CallYear := copy(S,27,2);
CallTime := copy(S,30,5);
CallDur := copy(S,36,8);
Number := copy(s,60,27);
CallRing: = copy(S,89,5);
Account:= copy(S,106,16);
end;

exports
ExtVar, InOut, Line, CallDate, CallMonth, CallYear, Calltime,
CallDur, Number, CallRing, Account;

end.
-------------------------------------
Application
interface
uses
Function VarCreate (S: string): string; stdcall; external 'collexconv.dll';

procedure TMainForm.CdrButtonOKClick(Sender: TObject);
begin
Assignfile(CdrText, CdrImportEdit.Text);
Reset(CdrText);
while not EOF(CdrText) do begin
ReadLn (CdrText, Buffer1);
ExtNum := ExtVar(Buffer1);//Problems here with Var not declared
OutgoingSQLEdit.Lines.Add(Extnum);
end;
CloseFile(CdrText);
end.
 
Looking at it again I had loads of bad statments. But I still cn not run the application. It seems to halt because of the follwing:

[Error} datacollex.pas(113): Not enough actual parameters

find the following bit of the application which it affects
procedure TMainForm.CdrButtonOKClick(Sender: TObject);

begin
Assignfile(CdrText, CdrImportEdit.Text);
Reset(CdrText);
while not EOF(CdrText) do begin
ReadLn (CdrText, Buffer1);
OutgoingSQLEdit.Lines.Add := ExtVar(buffer1);// Here is where it mentions a problem.
end;
CloseFile(CdrText);
end;
 
I Apoligise for this long post, but I am really getting stuck with my first DLL.
I'm a bit further ahead, but still getting stuck.

In My Dll Project I Have:


code:---------------------------------
library collexconv;

uses
ShareMem,
SysUtils,
Classes,
StringConv in 'StringConv.pas';

exports
ExtNum, CallDir, ExtLine, DateOfCall, MonthOfCall, YearOfCall, TimeOfCall,
LenOfcall, PhoneNum, RingLen, AcctNum;

{$R *.res}
Begin

end.
-------------------------------------------------------


I have the following in the unit:

code:--------------------------------------------------
unit StringConv;

interface
uses
SysUtils;

implementation
Var
ExtVar : string;
InOut : string;
Line : string;
CallDate : string;
CallMonth : string;
CallYear : string;
CallTime : string;
CallDur : string;
Number : string;
CallRing : string;
Account : string;

Function ExtNum (S: String): String; stdcall;
begin
ExtVar := copy(S,8,4);
end;
Function CallDir (S: String): String; stdcall;
Begin
InOut := copy(S,13,3);
end;
Function Extline (S: String): String; stdcall;
Begin
Line := copy(S,12,3);
end;
Function DateOfCall (S: String): String; stdcall;
Begin
CallDate := copy(S,21,2);
end;
Function MonthOfCall (S: String): String; stdcall;
Begin
CallMonth := copy(S,24,2);
end;
Function YearOfCall (S: String): String; stdcall;
Begin
CallYear := copy(S,27,2);
end;
Function TimeOfCall (S: String): String; stdcall;
Begin
CallTime := copy(S,30,5);
end;
Function LenOfCall (S: String): String; stdcall;
Begin
CallDur := copy(S,36,8);
end;
Function PhoneNum (S: String): String; stdcall;
Begin
Number := copy(s,60,27);
Number := StringReplace(Number, '.', '', [rfReplaceAll]);
end;
Function RingLen (S: String): String stdcall;
Begin
CallRing := copy(S,89,5);
end;
Function AcctNum (S: String): String stdcall;
Begin
Account:= copy(S,106,16);
Account := StringReplace(Account, '.', '', [rfReplaceAll]);
end;
end.
--------------------------------------------------


When I try to compile the DLL I get the following error in the project:
[Error] StringConv.pas(53): Undeclared identifier: 'ExtNum'
What have I missed.
 
Hi

Maybe something like this..

unit StringConv;

interface
uses
SysUtils;

Function ExtNum (S: String): String; stdcall;
Function CallDir (S: String): String; stdcall;
.
.
.
implementation
Var
ExtVar : string;
InOut : string;
.
.
.

Function ExtNum (S: String): String; stdcall;
begin
ExtVar := copy(S,8,4);
end;

Function CallDir (S: String): String; stdcall;
Begin
InOut := copy(S,13,3);
end;

.
.

cheers,
mha
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top