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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent help on who to coùmunicate to external application

Status
Not open for further replies.

newprog39

Programmer
Sep 26, 2015
15
0
0
DZ
Hi all:

I have imported a library of a software to delphi7 , I have got a file which called WINFIOLLib_TLB.pas.which contain a procedure and interface .

in order to comunicate to that sofware I have found this code on the net but it doesen't work properly .

the first fault I got is ':' expected but '=' found on TForm1 = class(TForm).

Code:
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
TWFEvent = class (TInterfacedObject, IWFEvent)

  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    OpenDialog1: TOpenDialog;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormDblClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure Notify(event: SYSINT; const text: WideString); safecall;

  end;

var
  Form1: TForm1;
  WinFIOL_Application1: TWinFIOL_Application;



implementation

{$R *.dfm}

procedure TWFEvent.Notify(event: SYSINT; const text: WideString); safecall;
begin;
Form1.Memo1.Lines.Add(IntToStr (Event));
Form1.Memo1.Lines.Add(String (Text));
procedure TForm1.FormDblClick(Sender: TObject);
Var
Ch: IWFChannel;
Event: TWFEvent;
begin
Ch := WinFiol_Application1.GetChannelPointer(WinFiol_Application1.GetCurrentChannel);
WinFiol_Application1.GetCurrentChannel <> 0
Event := TWFEvent.Create; //
EMask := WFEVENTMASK_ALL; //
Ch.Advise(Channel.Event, EMask);


end;



procedure TForm1.FormCreate(Sender: TObject);
begin
WinFIOL_Application1 := TWinFIOL_Application.Create(self);

end;

procedure TForm1.Button1Click(Sender: TObject);
Var
Chn_Name: String;
New_Ch: Integer;

begin
OpenDialog1.InitialDir := 'C:\Program Files\Element Management\ChnFiles';
If OpenDialog1.Execute Then Chn_Name := OpenDialog1.FileName Else Exit;
WinFIOL_Application1.OpenChannelFile(Chn_Name, 0, New_Ch);
WinFiol_Application1.GetChannelPointer(New_Ch).SetReadBuffer(512, 4);

end;
end.

NB: all fault code are summurized bellow:

[Error] Unit1.pas(25): Undeclared identifier: 'TWinFIOL_Application'
[Error] Unit1.pas(33): ';' expected but '.' found
[Error] Unit1.pas(33): '=' expected but ')' found
[Error] Unit1.pas(33): '=' expected but ';' found
[Error] Unit1.pas(34): Expression expected but 'BEGIN' found
[Error] Unit1.pas(35): Undeclared identifier: 'Event'
[Error] Unit1.pas(37): Statement expected but 'PROCEDURE' found
[Error] Unit1.pas(39): Undeclared identifier: 'IWFChannel'
[Error] Unit1.pas(40): Constant or type identifier expected

what is the wrong on this code ?

thanks for your help and suggestions
 
Simple, you must add WINFIOLLib_TLB to your uses list.

/Daddy

-----------------------------------------------------
Helping people is my job...
 
Hi whosrdaddy:

first I'm sorry to be late and thanks for your replying

I have copy both WINFIOLLib_TLB.pas and WINFIOLLib_TLB to project delphi directory but I still get the following error :

Expected ':' but '=' found.

[Fatal Error] Unit1.pas(7): Could not compile used unit 'WINFIOLLib_TLB.pas'
[Pascal Error] Unit1.pas(1): Unable to invoke Code Completion due to errors in source code

I have ajusted the code like this in use unit:

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,WINFIOLLib_TLB.pas;


just one thing is it true what I did in bellow declaration?

type
TWFEvent = class (TInterfacedObject, IWFEvent)

TForm1 = class(TForm)

thanks for your support and suggestion .
 
It seems to me that you don't have any Delphi experience at all :(

Your code is broken at so many levels I don't know where to start!

your code should be looking something like this:

Code:
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, WINFIOLLib_TLB;

type
  TWFEvent = class (TInterfacedObject, IWFEvent)
  public
    procedure Notify(event: SYSINT; const text: WideString); safecall;
  end;

  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    OpenDialog1: TOpenDialog;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormDblClick(Sender: TObject);
  private
    { Private declarations }
    WinFIOL_Application1: TWinFIOL_Application;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TWFEvent.Notify(event: SYSINT; const text: WideString); safecall;
begin;
  Form1.Memo1.Lines.Add(IntToStr (Event));
  Form1.Memo1.Lines.Add(String (Text));
end;

procedure TForm1.FormDblClick(Sender: TObject);

Var
  Ch: IWFChannel;
  Event: TWFEvent;

begin
 Ch := WinFiol_Application1.GetChannelPointer(WinFiol_Application1.GetCurrentChannel);
 Event := TWFEvent.Create; //
 EMask := WFEVENTMASK_ALL; //
 Ch.Advise(Channel.Event, EMask);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 WinFIOL_Application1 := TWinFIOL_Application.Create(self);
end;

procedure TForm1.Button1Click(Sender: TObject);

Var
  Chn_Name: String;
  New_Ch: Integer;

begin
 OpenDialog1.InitialDir := 'C:\Program Files\Element Management\ChnFiles';
 If OpenDialog1.Execute Then 
  Chn_Name := OpenDialog1.FileName 
 Else 
  Exit;
 WinFIOL_Application1.OpenChannelFile(Chn_Name, 0, New_Ch);
 WinFiol_Application1.GetChannelPointer(New_Ch).SetReadBuffer(512, 4);
end;

end.

/Daddy


-----------------------------------------------------
Helping people is my job...
 
Maybe I'm being a bit thick - but the line

[li][tt]WinFiol_Application1.GetCurrentChannel <> 0[/tt][/li]

as it doesn't seem to do anything; it's a Boolean statement but doesn't appear to be assigned anywhere
 
yes, that line makes no sense, the code is a mess.
I edited my response, thanks.

-----------------------------------------------------
Helping people is my job...
 
I recently installed Delphi 7 Enterprise on my machine - what a nightmare under Windows 10 and then trying to register it. I used to work a lot in Delphi, but for the last umpteen years it has been all .NET. I'm currently trying to regain my Delphi skills - but not easy with an 80% working IDE. I've spoken to Embarcadero, they helped me register the program and tell me there are no updates to 7. That's why I was a little reluctant to comment on the above code (both yours and the OP's)
 
Hi whosrdaddy:

thanks for your valuable remarks and support .

I counld'nt compile yet the project I still get one error:

Fatal Error] Unit1.pas(7): File not found: 'WINFIOLLib_TLB.pas.dcu'

thanks
 
check out my code and compare to yours. The error is fairly trivial.
You've added WINFIOLLib_TLB.pas to your uses clause while it should be WINFIOLLib_TLB...

/Daddy

-----------------------------------------------------
Helping people is my job...
 
Hi again:

when you add WINFIOLLib_TLB to uses you will get bellow errors:

Build
[Error] Unit1.pas(12): Undeclared identifier: 'SYSINT'
[Error] Unit1.pas(51): Undeclared identifier: 'EMask'
[Error] Unit1.pas(52): Undeclared identifier: 'Channel'
[Error] Unit1.pas(52): Statement expected, but expression of type 'TWFEvent' found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

that's why I have changed it just for test purpose .

just to add one thing:

WINFIOLLib_TLB.pas & WINFIOLLib_TLB.dcu are located in bellow directory is it normal ?

C:\Program Files\Borland\Delphi7\Imports
C:\Program Files\Borland\Delphi7\Projects
C:\Program Files\Borland\Delphi7\Lib

NB : if necessary I will send them to your email adress.

thanks
 
Did you even read my first answer?
Your code is broken.
Please try the code that I posted.

/Daddy

-----------------------------------------------------
Helping people is my job...
 
hi again :

this is the code I have used but I still have error :

Code:
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, WINFIOLLib_TLB;

type
  TWFEvent = class (TInterfacedObject, IWFEvent)
  public
    procedure Notify(event: SYSINT; const text: WideString); safecall;
  end;

  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    OpenDialog1: TOpenDialog;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormDblClick(Sender: TObject);
  private
    { Private declarations }
    WinFIOL_Application1: TWinFIOL_Application;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TWFEvent.Notify(event: SYSINT; const text: WideString); safecall;
begin;
  Form1.Memo1.Lines.Add(IntToStr (Event));
  Form1.Memo1.Lines.Add(String (Text));
end;

procedure TForm1.FormDblClick(Sender: TObject);

Var
  Ch: IWFChannel;
  Event: TWFEvent;

begin
 Ch := WinFiol_Application1.GetChannelPointer(WinFiol_Application1.GetCurrentChannel);
 Event := TWFEvent.Create; //
 EMask := WFEVENTMASK_ALL; //
 Ch.Advise(Channel.Event, EMask);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 WinFIOL_Application1 := TWinFIOL_Application.Create(self);
end;

procedure TForm1.Button1Click(Sender: TObject);

Var
  Chn_Name: String;
  New_Ch: Integer;

begin
 OpenDialog1.InitialDir := 'C:\Program Files\Element Management\ChnFiles';
 If OpenDialog1.Execute Then 
  Chn_Name := OpenDialog1.FileName 
 Else 
  Exit;
 WinFIOL_Application1.OpenChannelFile(Chn_Name, 0, New_Ch);
 WinFiol_Application1.GetChannelPointer(New_Ch).SetReadBuffer(512, 4);
end;

end.

 
The procedure Notify seems to start with a begin; !!!!! Tried to remove ';'?
May actually be ignored.

Do you need 'safecall' both at the declaration and in the code? (also Notify)
 
Hi walker2:

regarding begin; it was corrected .

for 'safecall' it is included in library imported .
 
Hi all:

in attachement two imported files to delphi .

thanks for your help
 
Hi all:

is there anyone who can help us ?

thanks
 
I copied the file from the link and the source code.
First you should add yhe "uses" units from the TLB file to the main unit as well.
Then I found errors in this part:


procedure TForm1.FormDblClick(Sender: TObject);
Var
Ch: IWFChannel;
Event: TWFEvent;
EMask : SYSINT;
begin
Ch := WinFiol_Application1.GetChannelPointer(WinFiol_Application1.GetCurrentChannel);
Event := TWFEvent.Create; //
EMask := $FF; //WFEVENTMASK_ALL; //
Ch.Advise(Event, EMask);
end;

EMask has never been declared and is only used here, so I added it to the Var part
Ch.Event is used in the "Advise c"all, but does not exist, so I left out the "Ch." part as "Event" was declared separately...
Could not find the "WFEVENTMASK_ALL" parameter and also not the type of "SYSINT", so just assumed a byte and used $FF as mask
By doing this the program compiles.
No idea what it should do of course.
Cheers, Joop
 
hi beunders:

thanks a lot of for your help .

the modification was applied but I have got this message :

Build
[Error] Unit1.pas(12): Undeclared identifier: 'SYSINT'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

the code is listed bellow:

Code:
interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, WINFIOLLib_TLB;

type
  TWFEvent = class (TInterfacedObject, IWFEvent)
  public
    procedure Notify(event: SYSINT; const text: WideString); safecall;
  end;

  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    OpenDialog1: TOpenDialog;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormDblClick(Sender: TObject);
  private
    { Private declarations }
    WinFIOL_Application1: TWinFIOL_Application;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TWFEvent.Notify(event: SYSINT; const text: WideString); safecall;
begin;
  Form1.Memo1.Lines.Add(IntToStr (Event));
  Form1.Memo1.Lines.Add(String (Text));
end;

procedure TForm1.FormDblClick(Sender: TObject);
Var
Ch: IWFChannel;
Event: TWFEvent;
EMask : SYSINT;
begin
Ch := WinFiol_Application1.GetChannelPointer(WinFiol_Application1.GetCurrentChannel);
Event := TWFEvent.Create; //
EMask := $FF; //WFEVENTMASK_ALL; //
Ch.Advise(Event, EMask);

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 WinFIOL_Application1 := TWinFIOL_Application.Create(self);
end;

procedure TForm1.Button1Click(Sender: TObject);

Var
  Chn_Name: String;
  New_Ch: Integer;

begin
 OpenDialog1.InitialDir := 'C:\Program Files\Element Management\ChnFiles';
 If OpenDialog1.Execute Then
  Chn_Name := OpenDialog1.FileName 
 Else 
  Exit;
 WinFIOL_Application1.OpenChannelFile(Chn_Name, 0, New_Ch);
 WinFiol_Application1.GetChannelPointer(New_Ch).SetReadBuffer(512, 4);
end;

end.

thanks again for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top