[fpc-pascal]OOP - What is wrong here? Please help!

Rainer Hantsch rainer at hantsch.co.at
Wed Oct 10 10:46:10 CEST 2001


Hello, all!
This is a testing version of my browser - currently only a very rudimentary 
skeleton, but even this makes troubles... 
I get the following error during compilation, but I do not understand the
reason. Can you, please, have a look on that?

This here is the unit which defines the object "oBrowser". It uses oCRT
because I write only telnet-applications.
--<snip>--------------------
unit browser;
{$H+}

INTERFACE

uses oCRT;

type
tListe = record
          s     : string;
	  prev,
	  next  : pointer; 
         end;
pListe = ^tListe;
						
						
oBrowser = object
            public
	    constructor Init(x1,y1,x2,y2,fra,bga: byte; hdr: string);
	    destructor  Done;
			
	    private
	    win		:	tnWindow;	// from oCRT
	    ListStart	:	pointer;
	    Liste	:	pListe;
	    procedure Load; virtual;
	  end;


IMPLEMENTATION

//////////////////////////////////////////////////////////////////////////
constructor oBrowser.Init(x1,y1,x2,y2,fra,bga: byte; hdr: string);
begin
	// Initialisieren der Liste
	ListStart:=nil;
	Liste:=nil;	
	
	// Laden der Daten in die Liste
	Load;
	
	// Öffnen des Fensters
	nMakeWindow(win, x1,y1,x2,y2,bga,fra,fra shl 4,true,left,hdr);
	win.show;
end;
//////////////////////////////////////////////////////////////////////////
destructor oBrowser.Done;
begin
	// Abbauen der Liste vom Heap
	while ListStart<>nil do
	begin
		Liste:=ListStart;
		ListStart:=Liste^.next;
		
		Liste^.s:='';			// Weil s=Ansistring, muß zuerst s auf '' gesetzt werden
		dispose(Liste);		// Freigeben des Elementes
	end;	

	// Fenster schließen
	Win.done;
end;
//////////////////////////////////////////////////////////////////////////
procedure oBrowser.Load;	// Dummy-Procedure 
begin
end;
//////////////////////////////////////////////////////////////////////////
begin
end.
--<snap>--------------------


This here is a main program for testing the above oBrowser. It should do here
only the following: OPEN a window, wait 6 seconds and then close the window
again...
--<snip>--------------------
// This is the main program for testing oBrowser...
program t;
{$H+}
uses oCRT, browser;

type
otest = object(oBrowser)
          procedure Load; virtual;
        end;
			  
procedure otest.load;
begin
end;


begin
	otest.Init(1,1,80,25,white,white,'Hallo');
	
	delay(6000);
	
	otest.done;
end.
--<snap>--------------------



if I try to compile "t.pp", I get the following error:

rainer at miraculix:~/freepascal/faktura > fpc t
Free Pascal Compiler version 1.0.4 [2000/12/18] for i386
Copyright (c) 1993-2000 by Florian Klaempfl
Target OS: Linux for i386
Compiling t.pp
Compiling browser.pp
Assembling browser
t.pp(16,8) Error: Only static variables can be used in static methods or
outside methods
t.pp(16,8) Error: Illegal expression
t.pp(16,8) Fatal: Syntax error, ; expected but identifier INIT found
rainer at miraculix:~/freepascal/faktura > 


WHY?


mfg

  Ing. Rainer Hantsch


      \\|//           Ing. Rainer HANTSCH  -  Hardware + Software
      (o o)           Forget Windoze! -- We focus on L-I-N-U-X...
--oOOo-(_)-oOOo--------------------------------------------------
Ing. Rainer HANTSCH  |  e-Mail: office at hantsch.co.at
Khunngasse 21/20     |  www   : http://www.hantsch.co.at
A-1030 Vienna        |  Tel.  : ++43 - 1 - 7988538 0 
---------------------|  Fax   : ++43 - 1 - 7988538 18
** AUSTRIA **        |  Mobile: ++43 - 663 - 9194382
-----------------------------------------------------------------






More information about the fpc-pascal mailing list