[fpc-pascal] sax.pp

Tony Pelton tpelton at gmail.com
Wed Dec 28 00:28:43 CET 2005


On 12/27/05, L505 <fpc505 at z505.com> wrote:
>
> Would need to see some sample code that is giving you the abstract error, though. I
> just finished dealing with an "abstract error" and all I did was forget to place the
> override keyword after the function declaration in the *derivative* class.

thanks for the response.

i'm including some code.

it compiles, but generates a runtime error :

An unhandled exception occurred at $0040691E :
EAbstractError : Abstract method called

with java, unless you are hiding the implementation from the compiler,
by using runtime classloading for instance, the compiler will tell you
that you are trying to use an abstract class and what abstract thing
you are trying to use and that it is bad and wrong.

so this pascal code wouldn't get past the compiler were it java.

note that i was just trying to get to a starting point of being able
to capture "character" events from the parser and write them to
stdout, nothing more.

also note that i've got all of the other events commented out for starters.

i must be missing something blatant, likely due to my inexperience with pascal.

thanks for any help.

Tony

PS. btw, a url (http://x-plane.dsrts.com/screenshot_0.bmp) with a
screenshot of a "plugin" i've written for a flight simulator using
FPC, and to which this issue is related.

all of the "brightly colored" bits that you see in the screenshot are
the work of my plugin within the simulator and is all written in
pascal as a windows DLL using OpenGL calls.

The simulator API also supports 'C', but I had come close to suicide
on more than one occassion trying to write 'C' and had almost given
up, when i thought to try FreePascal.

i've never looked back.

'C' sucks, FreePascal ROCKS !

-- SNIP --
program Main;

Uses
// heaptrc,
 SAX,
 Classes,
 Objects,
 Math,
 StrUtils,
 SysUtils;

Type Tmyfilter = class(TSAXFilter)
procedure DoCharacters(const ch: PSAXChar; AStart, ALength: Integer); override;
end;

procedure Tmyfilter.DoCharacters(const ch: PSAXChar; AStart, ALength: Integer);
begin
WriteLn(StrPas(PChar(ch)));
end;

{
procedure DoCharacters(const ch: PSAXChar; AStart, ALength: Integer); dynamic;
procedure DoComment(const ch: PSAXChar; AStart, ALength: Integer); dynamic;
procedure DoEndDocument; dynamic;
procedure DoEndElement(const NamespaceURI, LocalName, QName:
SAXString); dynamic;
procedure DoEndPrefixMapping(const Prefix: SAXString); dynamic;
procedure DoIgnorableWhitespace(const ch: PSAXChar; AStart, ALength:
Integer); dynamic;
procedure DoProcessingInstruction(const Target, Data: SAXString); dynamic;
procedure DoSkippedEntity(const Name: SAXString); dynamic;
procedure DoStartDocument; dynamic;
procedure DoStartElement(const NamespaceURI, LocalName, QName:
SAXString; Atts: TSAXAttributes); dynamic;
procedure DoStartPrefixMapping(const Prefix, URI: SAXString); dynamic;
}

Type TDosStreamPtr = ^TDosStream;

Var a_name : FNameStr;
Var a_stream : TDosStreamPtr;
Var a_filter : Tmyfilter;

begin
a_name := 'google_earth_tutorial_files.kml';
a_stream := new(TDosStreamPtr,Init(a_name,stOpenRead));

a_filter := TmyFilter.Create;
a_filter.ParseStream(@a_stream);
end.



More information about the fpc-pascal mailing list