Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-12

calling a procedure from another pas file

8 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

LeVA

Hi!

First of all, Merry Christmas to everyone :)

Now my question :)

I have a procedure (let's say test_proced) in my main.pas file, and I can call it from there, and it works. I have another pas file, called test.pas. I want to call the test_proced procedure from that test.pas. I have added this under the test.pas's implementation section:

uses main;

Now I can use main.pas's variables, but still can not call that procedure.

How can I do this?

Thanks!

Daniel

LeVA

Reply by email

Vincent Snijders
to LeVA

Put the declaration behind the uses section in the interface section.

unit main;
{$mode objfpc}{$H+}
interface

uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,

   StdCtrls, Buttons, Menus;
procedure kocsi_olvas(hogy_mit: char; marka: string; tipus: string);

type
TForm1 = class(TForm)
etc

HTH,
Vincent.

Show quoted text 51 lines
Vincent Snijders wrote: > Do you have > procedure kocsi_olvas (hogy_mit: char; marka: string; tipus: > string); in the interface section of the unit main? --------------------------###-------------------------- unit main; {$mode objfpc}{$H+} interface procedure kocsi_olvas(hogy_mit: char; marka: string; tipus: string); uses Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Buttons, Menus; type TForm1 = class(TForm) ..... .... ... .. . --------------------------###-------------------------- No, I don't have, but I put it under the Interface section, and when trying to build, I get this: --------------------------###-------------------------- TOutputFilter: "Compiling main.pas" TOutputFilter: "main.pas(8,1) Fatal: Syntax error, "IMPLEMENTATION" expected but "USES" found" --------------------------###-------------------------- I tried to put that ( procedure kocsi_olvas(hogy_mit: char; marka: string; tipus: string); ) line under the 'public', 'private' and 'implementation' section in main.pas, but I get the TOutputFilter: "test.pas(55,12) Error: Identifier not found "kocsi_olvas"" TOutputFilter: "test.pas(55,46) Error: Illegal expression" lines every time. Any idea? Daniel

Reply by email

LeVA
to LeVA: Hi! First of all, Merry Christmas to everyone :) Now my question :) I have a procedure…
LeVA wrote 20 lines
Hi! First of all, Merry Christmas to everyone :) Now my question :) I have a procedure (let's say test_proced) in my main.pas file, and I can call it from there, and it works. I have another pas file, called test.pas. I want to call the test_proced procedure from that test.pas. I have added this under the test.pas's implementation section: uses main; Now I can use main.pas's variables, but still can not call that procedure. How can I do this? Thanks! Daniel

Should I explain more precisely what is my problem, or this is not possible with lazarus/fpc?

Show quoted text 9 lines
-- LeVA _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
LeVA

Reply by email

Vincent Snijders
to LeVA: Hi! First of all, Merry Christmas to everyone :) Now my question :) I have a procedure…

Do you have
procedure kocsi_olvas (hogy_mit: char; marka: string; tipus: string); in the interface section of the unit main?

HTH,
Vincent.

Show quoted text 88 lines
I have a main.pas file. main.pas: ----------------------------###---------------------------- procedure kocsi_olvas (hogy_mit: char; marka: string; tipus: string); var sor :string[255]; i :byte; const kocsi_file='kocsi.lst'; begin blabla case hogy_mit of 'm': begin blabla end; 't': begin blabla end; 'r': begin blabla end; end; end; ----------------------------###---------------------------- I have a test.pas file. test.pas: ----------------------------###---------------------------- .. ... .... ..... var Form6: TForm6; implementation uses main; { TForm6 } { TForm6 } { TForm6 } procedure TForm6.Form6Show(Sender: TObject); var marka : string[255]; tipus : string[255]; sor : string[255]; i : integer; begin blabla while markak[i]'' do begin blabla kocsi_olvas('t',markak[i],'tipus'); blabla end; end; ----------------------------###---------------------------- And when I build the project, I get this in the messages window: ----------------------------###---------------------------- TOutputFilter: "test.pas(55,12) Error: Identifier not found "kocsi_olvas"" TOutputFilter: "test.pas(55,46) Error: Illegal expression" TOutputFilter: "test.pas(113) Fatal: There were 2 errors compiling module, stopping" ----------------------------###---------------------------- I thought that specifying the 'main' in the uses section is enough for calling the procedure. I can read/write the main.pas's variables, but can not call the main.pas's 'kocsi_olvas' procedure. Thanks for the help! Daniel -- LeVA _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

LeVA
to LeVA: Hi! First of all, Merry Christmas to everyone :) Now my question :) I have a procedure…
Vincent Snijders wrote
Do you have procedure kocsi_olvas (hogy_mit: char; marka: string; tipus: string); in the interface section of the unit main?
--------------------------###--------------------------
unit main;
{$mode objfpc}{$H+}
interface
procedure kocsi_olvas(hogy_mit: char; marka: string; tipus: string);

uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,

   StdCtrls, Buttons, Menus;
type
   TForm1 = class(TForm)

.....
....
...
..
.
--------------------------###--------------------------

No, I don't have, but I put it under the Interface section, and when trying to build, I get this:

--------------------------###-------------------------- TOutputFilter: "Compiling main.pas"
TOutputFilter: "main.pas(8,1) Fatal: Syntax error, "IMPLEMENTATION" expected but "USES" found"
--------------------------###--------------------------

I tried to put that ( procedure kocsi_olvas(hogy_mit: char; marka: string; tipus: string); ) line under the 'public', 'private' and 'implementation' section in main.pas, but I get the

TOutputFilter: "test.pas(55,12) Error: Identifier not found "kocsi_olvas""
TOutputFilter: "test.pas(55,46) Error: Illegal expression"

lines every time.

Any idea?

Daniel

Show quoted text 79 lines
>I have a main.pas file. >main.pas: > >----------------------------###---------------------------- >procedure kocsi_olvas (hogy_mit: char; marka: string; tipus: string); > var sor :string[255]; > i :byte; > > const kocsi_file='kocsi.lst'; >begin > blabla > case hogy_mit of > 'm': begin blabla end; > 't': begin blabla end; > 'r': begin blabla end; > end; >end; >----------------------------###---------------------------- > > >I have a test.pas file. >test.pas: > >----------------------------###---------------------------- >.. >... >.... >..... >var > Form6: TForm6; > >implementation > >uses > main; > >{ TForm6 } > >{ TForm6 } > >{ TForm6 } > >procedure TForm6.Form6Show(Sender: TObject); > var marka : string[255]; > tipus : string[255]; > sor : string[255]; > i : integer; > >begin > blabla > while markak[i]'' do > begin > blabla > kocsi_olvas('t',markak[i],'tipus'); > blabla > end; >end; >----------------------------###---------------------------- > > >And when I build the project, I get this in the messages window: > >----------------------------###---------------------------- >TOutputFilter: "test.pas(55,12) Error: Identifier not found >"kocsi_olvas"" TOutputFilter: "test.pas(55,46) Error: Illegal >expression" TOutputFilter: "test.pas(113) Fatal: There were 2 errors >compiling module, stopping" >----------------------------###---------------------------- > > > >I thought that specifying the 'main' in the uses section is enough for > >calling the procedure. I can read/write the main.pas's variables, but >can not call the main.pas's 'kocsi_olvas' procedure. > >Thanks for the help! > >Daniel
LeVA

Reply by email

LeVA
to LeVA: Hi! First of all, Merry Christmas to everyone :) Now my question :) I have a procedure…
Mattias Gaertner wrote 36 lines
On Sat, 27 Dec 2003 13:43:44 +0100 LeVA wrote: >LeVA wrote: > >>Hi! >> >>First of all, Merry Christmas to everyone :) >> >>Now my question :) >> >>I have a procedure (let's say test_proced) in my main.pas file, and I >>can call it from there, and it works. I have another pas file, called >>test.pas. I want to call the test_proced procedure from that test.pas. I >> >>have added this under the test.pas's implementation section: >> >>uses main; >> >>Now I can use main.pas's variables, but still can not call that >>procedure. >> >>How can I do this? >> >>Thanks! >> >>Daniel > >Should I explain more precisely what is my problem, or this is not >possible with lazarus/fpc? Almost all units call procs in other units. Plz give more details. Mattias

I have a main.pas file.
main.pas:

----------------------------###----------------------------
procedure kocsi_olvas (hogy_mit: char; marka: string; tipus: string);
     var     sor       :string[255];
             i         :byte;
     const   kocsi_file='kocsi.lst';
begin
    blabla
    case hogy_mit of
         'm': begin blabla end;
         't': begin blabla end;
         'r': begin blabla end;
    end;
end;
----------------------------###----------------------------

I have a test.pas file.
test.pas:

----------------------------###---------------------------- ..
...
....
.....
var

   Form6: TForm6;
implementation
uses
    main;

{ TForm6 }

{ TForm6 }

{ TForm6 }

procedure TForm6.Form6Show(Sender: TObject);
     var     marka  : string[255];
             tipus  : string[255];
             sor    : string[255];
             i      : integer;
begin
    blabla
    while markak[i]'' do
      begin
       blabla
       kocsi_olvas('t',markak[i],'tipus');
       blabla
      end;
end;
----------------------------###----------------------------

And when I build the project, I get this in the messages window:

----------------------------###---------------------------- TOutputFilter: "test.pas(55,12) Error: Identifier not found "kocsi_olvas"" TOutputFilter: "test.pas(55,46) Error: Illegal expression" TOutputFilter: "test.pas(113) Fatal: There were 2 errors compiling module, stopping"
----------------------------###----------------------------

I thought that specifying the 'main' in the uses section is enough for calling the procedure. I can read/write the main.pas's variables, but can not call the main.pas's 'kocsi_olvas' procedure.

Thanks for the help!

Daniel

LeVA

Reply by email

LeVA
to LeVA: Hi! First of all, Merry Christmas to everyone :) Now my question :) I have a procedure…
Vincent Snijders wrote 22 lines
Put the declaration behind the uses section in the interface section. unit main; {$mode objfpc}{$H+} interface uses Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Buttons, Menus; procedure kocsi_olvas(hogy_mit: char; marka: string; tipus: string); type TForm1 = class(TForm) etc HTH, Vincent.

Yes, thank you. Now it works. I don't know what would I do without you guys :)

Thanks again.

Daniel

Show quoted text 57 lines
On Sat, 27 Dec 2003 15:53:06 +0100 LeVA wrote: >Vincent Snijders wrote: > >>Do you have >>procedure kocsi_olvas (hogy_mit: char; marka: string; tipus: >>string); in the interface section of the unit main? > >--------------------------###-------------------------- >unit main; > >{$mode objfpc}{$H+} > >interface > >procedure kocsi_olvas(hogy_mit: char; marka: string; tipus: string); > >uses > Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, >ExtCtrls, > StdCtrls, Buttons, Menus; > >type > TForm1 = class(TForm) > >..... >.... >... >.. >. >--------------------------###-------------------------- > >No, I don't have, but I put it under the Interface section, and when >trying to build, I get this: > >--------------------------###-------------------------- >TOutputFilter: "Compiling main.pas" >TOutputFilter: "main.pas(8,1) Fatal: Syntax error, "IMPLEMENTATION" >expected but "USES" found" >--------------------------###-------------------------- > >I tried to put that ( procedure kocsi_olvas(hogy_mit: char; marka: >string; tipus: string); ) line under the 'public', 'private' and >'implementation' section in main.pas, but I get the > >TOutputFilter: "test.pas(55,12) Error: Identifier not found >"kocsi_olvas"" TOutputFilter: "test.pas(55,46) Error: Illegal >expression" > >lines every time. > >Any idea? > >Daniel
LeVA

Reply by email

Mattias Gaertner
to LeVA: Hi! First of all, Merry Christmas to everyone :) Now my question :) I have a procedure…
Show quoted text 26 lines
LeVA wrote: > Hi! > > First of all, Merry Christmas to everyone :) > > Now my question :) > > I have a procedure (let's say test_proced) in my main.pas file, and I > can call it from there, and it works. I have another pas file, called > test.pas. I want to call the test_proced procedure from that test.pas. I > > have added this under the test.pas's implementation section: > > uses main; > > Now I can use main.pas's variables, but still can not call that > procedure. > > How can I do this? > > Thanks! > > Daniel Should I explain more precisely what is my problem, or this is not possible with lazarus/fpc?

Almost all units call procs in other units. Plz give more details.

Mattias

Reply by email