INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Urgent help on who to coùmunicate to external application

Urgent help on who to coùmunicate to external application

(OP)
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

RE: Urgent help on who to coùmunicate to external application

Simple, you must add WINFIOLLib_TLB to your uses list.

/Daddy

-----------------------------------------------------
Helping people is my job...

RE: Urgent help on who to coùmunicate to external application

(OP)
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 .

RE: Urgent help on who to coùmunicate to external application

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...

RE: Urgent help on who to coùmunicate to external application

Maybe I'm being a bit thick - but the line

  • WinFiol_Application1.GetCurrentChannel <> 0


  • as it doesn't seem to do anything; it's a Boolean statement but doesn't appear to be assigned anywhere

    RE: Urgent help on who to coùmunicate to external application

    yes, that line makes no sense, the code is a mess.
    I edited my response, thanks.

    -----------------------------------------------------
    Helping people is my job...

    RE: Urgent help on who to coùmunicate to external application

    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)

    RE: Urgent help on who to coùmunicate to external application

    (OP)
    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

    RE: Urgent help on who to coùmunicate to external application

    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...

    RE: Urgent help on who to coùmunicate to external application

    (OP)
    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

    RE: Urgent help on who to coùmunicate to external application

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

    /Daddy

    -----------------------------------------------------
    Helping people is my job...

    RE: Urgent help on who to coùmunicate to external application

    (OP)
    HI whosrdaddy:

    I have used your code .

    thanks

    RE: Urgent help on who to coùmunicate to external application

    (OP)
    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. 

    RE: Urgent help on who to coùmunicate to external application

    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)

    RE: Urgent help on who to coùmunicate to external application

    (OP)
    Hi walker2:

    regarding begin; it was corrected .

    for 'safecall' it is included in library imported .

    RE: Urgent help on who to coùmunicate to external application

    (OP)
    Hi all:

    in attachement two imported files to delphi .

    thanks for your help

    RE: Urgent help on who to coùmunicate to external application

    (OP)
    Hi all:

    is there anyone who can help us ?

    thanks

    RE: Urgent help on who to coùmunicate to external application

    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

    RE: Urgent help on who to coùmunicate to external application

    (OP)
    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.

    RE: Urgent help on who to coùmunicate to external application

    You should add the libraries which are in your USES statement in the TLB file to your main file
    Cheers,
    Joop

    RE: Urgent help on who to coùmunicate to external application

    (OP)
    hi again:

    you mean this :

    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

    thanks

    RE: Urgent help on who to coùmunicate to external application

    No , I mean the libraries which are in the TLB file in the uses statement .
    It shows:
    uses Windows, ActiveX, Classes, Graphics, OleServer, StdVCL, Variants;

    In your main file are:
    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, WINFIOLLib_TLB;

    So you need to add the ones which are not already in the main clause:
    ActiveX, OleServer and StdVcl.

    In at least one of these the SYSINT is declared.
    (I did not check in which).
    Success,
    Joop



    RE: Urgent help on who to coùmunicate to external application

    (OP)
    hi :

    now I get the point , thaks a lot of it compile .

    greeting

    RE: Urgent help on who to coùmunicate to external application

    Newprog39,

    I don't understand, this is the thing I said numerous times??

    Do you know how to Copy and paste?

    *Sigh*

    -----------------------------------------------------
    Helping people is my job...

    Red Flag This Post

    Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

    Red Flag Submitted

    Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
    The Tek-Tips staff will check this out and take appropriate action.

    Reply To This Thread

    Posting in the Tek-Tips forums is a member-only feature.

    Click Here to join Tek-Tips and talk with other members!

    Resources

    Close Box

    Join Tek-Tips® Today!

    Join your peers on the Internet's largest technical computer professional community.
    It's easy to join and it's free.

    Here's Why Members Love Tek-Tips Forums:

    Register now while it's still free!

    Already a member? Close this window and log in.

    Join Us             Close