Sign in Join

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

Mailing lists / fpc-pascal / 2006-06

exiting a program more friendly way

5 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

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

Pianoman

Hi, I'd like to ask whether is it possible to exit program in case of runtime error 202 for example more nicely than with message runtime error 202 at a1d456d5621blablabla
For example:
writeln('starting to divide:');
writeln(2/0);
and I don't want mi program to stop with runtime error but I 'd like to write to screen something like: writeln('program has atempted to divide by zero enter another expression.');
old tp had a special procedure exitproc which allowed to set which code should be executed before terminating in case of run-time error. I mean code which will close opened files or something like that or it could write to logfile the reason of error.
Thanx in advance
Pianoman----- Original Message -----
From:
To:
Sent: Friday, June 23, 2006 5:32 AM
Subject: fpc-pascal Digest, Vol 22, Issue 11

Show quoted text 543 lines
Send fpc-pascal mailing list submissions to To subscribe or unsubscribe via the World Wide Web, visit http://lists.freepascal.org/mailman/listinfo/fpc-pascal or, via email, send a message with subject or body 'help' to You can reach the person managing the list at When replying, please edit your Subject line so it is more specific than "Re: Contents of fpc-pascal digest..." Today's Topics: 1. Re: Internal error 200203271 (Steve Williams) 2. Re: Internal error 200203271 (Marco van de Voort) 3. Re: Internal error 200203271 (Steve Williams) 4. Re: Internal error 200203271 (Steve Williams) 5. Re: Internal error 200203271 (Peter Vreman) 6. Re: Internal error 200203271 (Marco van de Voort) 7. Modify XML Document (Felipe Monteiro de Carvalho) 8. Re: Modify XML Document (Tony Pelton) ---------------------------------------------------------------------- Message: 1 Date: Thu, 22 Jun 2006 20:30:33 +1000 From: Steve Williams Subject: Re: [fpc-pascal] Internal error 200203271 To: FPC-Pascal users discussions Message-ID: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Steve Williams wrote: > Koenraad Lelong wrote: > >> Hi, >> When I ty to compile fpc-svn for arm-linux it stops with Internal error >> 200203271 when buildgtk2.pp/gtkspinbutton.inc is compiled. >> >> > > Was there a solution for this? I've just come across this error now > while trying to build fpc-svn for arm-linux as well. I'm using the > following command line on Win32 from the root of the fpc source tree. > > make all OS_TARGET=linux CPU_TARGET=arm > CROSSBINDIR=c:\devkitpro\devkitgp2x\bin BINUTILSPREFIX=arm-linux- > I want to make sure I have this right. I wish to build ppcarm.exe that runs on Win32 and will create an arm-linux ELF. Is OS_TARGET and CPU_TARGET as used above correct? Or do I use PPC_TARGET=arm? Is there any documentation on these parameters? The Build FAQ gives an example of building a compiler to run on another system. I want to build a compiler to run on my system that can build executables for another system. -- Sly This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect. ------------------------------ Message: 2 Date: Thu, 22 Jun 2006 13:28:31 +0200 (CEST) From: (Marco van de Voort) Subject: Re: [fpc-pascal] Internal error 200203271 To: FPC-Pascal users discussions Message-ID: Content-Type: text/plain; charset="US-ASCII" > > Was there a solution for this? I've just come across this error now > > while trying to build fpc-svn for arm-linux as well. I'm using the > > following command line on Win32 from the root of the fpc source tree. > > > > make all OS_TARGET=linux CPU_TARGET=arm > > CROSSBINDIR=c:\devkitpro\devkitgp2x\bin BINUTILSPREFIX=arm-linux- > > > > I want to make sure I have this right. I wish to build ppcarm.exe that > runs on Win32 and will create an arm-linux ELF. Is OS_TARGET and > CPU_TARGET as used above correct? Or do I use PPC_TARGET=arm? Is there > any documentation on these parameters? The Build FAQ gives an example > of building a compiler to run on another system. I want to build a > compiler to run on my system that can build executables for another > system. Try make cycle instead rest the same. If you want to do it using make all that is all possible, but then you probably also need a OPT='-darm' ------------------------------ Message: 3 Date: Thu, 22 Jun 2006 23:00:34 +1000 From: Steve Williams Subject: Re: [fpc-pascal] Internal error 200203271 To: FPC-Pascal users discussions Message-ID: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Marco van de Voort wrote: >>> Was there a solution for this? I've just come across this error now >>> while trying to build fpc-svn for arm-linux as well. I'm using the >>> following command line on Win32 from the root of the fpc source tree. >>> >>> make all OS_TARGET=linux CPU_TARGET=arm >>> CROSSBINDIR=c:\devkitpro\devkitgp2x\bin BINUTILSPREFIX=arm-linux- >>> >>> >> I want to make sure I have this right. I wish to build ppcarm.exe that >> runs on Win32 and will create an arm-linux ELF. Is OS_TARGET and >> CPU_TARGET as used above correct? Or do I use PPC_TARGET=arm? Is there >> any documentation on these parameters? The Build FAQ gives an example >> of building a compiler to run on another system. I want to build a >> compiler to run on my system that can build executables for another >> system. >> > > Try make cycle instead rest the same. > > If you want to do it using make all that is all possible, but then you > probably also need a OPT='-darm' > There is no 'make cycle' target at the root of the fpc source tree. Tried the OPT='-darm' option, but now it stops with the error "ONLY one of the switches for the CPU type must be defined" because make puts -di386 in there. This is the command line. d:\fpc>make all OS_TARGET=linux CPU_TARGET=arm CROSSBINDIR=c:\devkitpro\devkitgp2x\bin BINUTILSPREFIX=arm-linux- OPT='-darm' I can get a ppcarm.exe compiled by using PPC_TARGET=arm, but I still need to get the arm-linux units compiled. -- Sly This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect. ------------------------------ Message: 4 Date: Fri, 23 Jun 2006 00:27:21 +1000 From: Steve Williams Subject: Re: [fpc-pascal] Internal error 200203271 To: FPC-Pascal users discussions Message-ID: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Steve Williams wrote: > Marco van de Voort wrote: > >> Try make cycle instead rest the same. >> >> If you want to do it using make all that is all possible, but then you >> probably also need a OPT='-darm' >> >> > > There is no 'make cycle' target at the root of the fpc source tree. > Tried the OPT='-darm' option, but now it stops with the error "ONLY one > of the switches for the CPU type must be defined" because make puts > -di386 in there. > > This is the command line. > d:\fpc>make all OS_TARGET=linux CPU_TARGET=arm > CROSSBINDIR=c:\devkitpro\devkitgp2x\bin BINUTILSPREFIX=arm-linux- > OPT='-darm' > > I can get a ppcarm.exe compiled by using PPC_TARGET=arm, but I still > need to get the arm-linux units compiled. > Without OPT='-darm', still get the internal error 200203271 on gtkspinbutton.inc(267,4). Trying again with OPT='-dGTK_DISABLE_DEPRECATED', but it will be about an hour before make gets to that point in the build again. -- Sly This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect. ------------------------------ Message: 5 Date: Thu, 22 Jun 2006 18:34:33 +0200 From: Peter Vreman Subject: Re: [fpc-pascal] Internal error 200203271 To: FPC-Pascal users discussions Message-ID: Content-Type: text/plain; charset="us-ascii"; format=flowed At 12:30 22-6-2006, you wrote: >Steve Williams wrote: >>Koenraad Lelong wrote: >> >>>Hi, >>>When I ty to compile fpc-svn for arm-linux it stops with Internal >>>error 200203271 when buildgtk2.pp/gtkspinbutton.inc is compiled. >>> >>> >> >>Was there a solution for this? I've just come across this error >>now while trying to build fpc-svn for arm-linux as well. I'm using >>the following command line on Win32 from the root of the fpc source tree. >> >>make all OS_TARGET=linux CPU_TARGET=arm >>CROSSBINDIR=c:\devkitpro\devkitgp2x\bin BINUTILSPREFIX=arm-linux- >> > >I want to make sure I have this right. I wish to build ppcarm.exe >that runs on Win32 and will create an arm-linux ELF. Is OS_TARGET >and CPU_TARGET as used above correct? Or do I use >PPC_TARGET=arm? Is there any documentation on these >parameters? The Build FAQ gives an example of building a compiler >to run on another system. I want to build a compiler to run on my >system that can build executables for another system. The commandline is correct. It will give you both a cross compiler called ppcrossarm and a native compiler called ppcarm. The IE is a code generation bug. That needs to be debugged. You can compile with OPT='-gl -dEXTDEBUG' to get a backtrace were the IE happends in the compiler. Peter ------------------------------ Message: 6 Date: Thu, 22 Jun 2006 22:37:18 +0200 (CEST) From: (Marco van de Voort) Subject: Re: [fpc-pascal] Internal error 200203271 To: FPC-Pascal users discussions Message-ID: Content-Type: text/plain; charset="US-ASCII" > >PPC_TARGET=arm? Is there any documentation on these > >parameters? The Build FAQ gives an example of building a compiler > >to run on another system. I want to build a compiler to run on my > >system that can build executables for another system. > > The commandline is correct. It will give you both a cross compiler > called ppcrossarm and a native compiler called ppcarm. > > The IE is a code generation bug. That needs to be debugged. You can > compile with OPT='-gl -dEXTDEBUG' to get a backtrace were the IE > happends in the compiler. make[6]: Entering directory :/repo/fpcex/packages/extra/gtk/gtkgl' D:/repo/fpcex/compiler/ppcrossarm.exe -Tlinux -Parm -XParm-linux- -Xc -Xr -XX -C X -Ur -Xs -O2 -n -FuD:/repo/fpcex/rtl/units/arm-linux -FuD:/repo/fpcex/packages/ extra/x11/units/arm-linux -FuD:/repo/fpcex/packages/extra/opengl/units/arm-linux -FDd:\repo\cross\arm-linux -FE. -FUD:/repo/fpcex/packages/extra/gtk/units/arm-l inux -dEXTDEBUG -gl -darm -dRELEASE gtkglarea.pp D:\repo\fpcex\packages\extra\gtk\units\arm-linux\gtkglarea.sl d:\repo\cross\arm-linux\arm-linux-ar.exe: creating D:\repo\fpcex\packages\extra\ gtk\units\arm-linux\libpgtkglarea.a D:\repo\fpcex\packages\extra\gtk\units\arm-linux\gtkglarea.sl Max Memory used/heapsize: 13.791/14.592 Kb make[6]: Leaving directory :/repo/fpcex/packages/extra/gtk/gtkgl' make[5]: Leaving directory :/repo/fpcex/packages/extra/gtk' make[4]: Leaving directory :/repo/fpcex/packages/extra/gtk' make -C gtk2 smart make[4]: Entering directory :/repo/fpcex/packages/extra/gtk2' make all LINKSMART=1 CREATESMART=1 make[5]: Entering directory :/repo/fpcex/packages/extra/gtk2' d:/pp11/bin/i386-win32/gmkdir.exe -p units/arm-linux D:/repo/fpcex/compiler/ppcrossarm.exe -Tlinux -Parm -XParm-linux- -Xc -Xr -XX -C X -Ur -Xs -O2 -n -Fuglib -Fuatk -Fupango -Fugtk+/gdk-pixbuf -Fugtk+/gdk -Fugtk+/ gtk -Fulibglade -Fugtkglext -FuD:/repo/fpcex/rtl/units/arm-linux -FDd:\repo\cros s\arm-linux -FE. -FUunits/arm-linux -dEXTDEBUG -gl -darm -dRELEASE buildgtk2.pp units\arm-linux\glib2.sl d:\repo\cross\arm-linux\arm-linux-ar.exe: creating units\arm-linux\libpglib2.a units\arm-linux\glib2.sl units\arm-linux\atk.sl d:\repo\cross\arm-linux\arm-linux-ar.exe: creating units\arm-linux\libpatk.a units\arm-linux\atk.sl units\arm-linux\pango.sl d:\repo\cross\arm-linux\arm-linux-ar.exe: creating units\arm-linux\libppango.a units\arm-linux\pango.sl units\arm-linux\gdk2pixbuf.sl d:\repo\cross\arm-linux\arm-linux-ar.exe: creating units\arm-linux\libpgdk2pixbu f.a units\arm-linux\gdk2pixbuf.sl units\arm-linux\gdk2.sl d:\repo\cross\arm-linux\arm-linux-ar.exe: creating units\arm-linux\libpgdk2.a units\arm-linux\gdk2.sl gtkspinbutton.inc(267,4) Fatal: Internal error 200203271 $004DF30F SECONDPASS, line 175 of pass_2.pas $0049DA27 DO_GENERATE_CODE, line 1274 of psub.pas $0049DFD9 READ_DECLARATIONS, line 1584 of psub.pas $00447E2D COMPILE, line 422 of parser.pas $0049122A TPPUMODULE__LOADPPU, line 1411 of fppu.pas $00499C5F LOADUNITS, line 602 of pmodules.pas $0049A55A PROC_UNIT, line 918 of pmodules.pas $00447E2D COMPILE, line 422 of parser.pas $0041C985 COMPILE, line 375 of compiler.pas Fatal: Compilation aborted Max Memory used/heapsize: 33.348/34.304 Kb make[5]: *** [buildgtk2.ppu] Error 1 make[5]: Leaving directory :/repo/fpcex/packages/extra/gtk2' make[4]: *** [fpc_smart] Error 2 make[4]: Leaving directory :/repo/fpcex/packages/extra/gtk2' make[3]: *** [gtk2_smart] Error 2 make[3]: Leaving directory :/repo/fpcex/packages/extra' make[2]: *** [extra_smart] Error 2 make[2]: Leaving directory :/repo/fpcex/packages' make[1]: *** [packages_extra_smart] Error 2 make[1]: Leaving directory :/repo/fpcex' make: *** [build-stamp.arm-linux] Error 2 ------------------------------ Message: 7 Date: Thu, 22 Jun 2006 23:46:10 -0300 From: "Felipe Monteiro de Carvalho" Subject: [fpc-pascal] Modify XML Document To: "FPC-Pascal users discussions" Message-ID: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hello, I am trying to use the units XMLRead, XMLWrite, DOM to modify the structure of a XML file. Reading the XML file is very easy and works very well, but I am lost about how to modify it´s structure. Specifically I want to add a new "brother" to a node. I try to create a DomNode and then add it, but I cannot change the NodeName property. So how can I change the name of a newly created node?? Also, how can I add a new Attribute to a DomNode?? The following code will give an error because NodeName is read-only: var NovoNo: TDomNode; begin Posicao := TreeView1.Selected.Index; NovoNo := TDomNode.Create(XMLDoc); NovoNo.NodeName := 'categoria'; XMLDoc.DocumentElement.InsertBefore(NovoNo, XMLDoc.DocumentElement.ChildNodes.Item[Posicao]); I looked at the examples on fpcsrc, but there are only very basic ones about xml. Any help e very welcome. thanks a lot, -- Felipe Monteiro de Carvalho ------------------------------ Message: 8 Date: Thu, 22 Jun 2006 23:31:15 -0400 From: "Tony Pelton" Subject: Re: [fpc-pascal] Modify XML Document To: "FPC-Pascal users discussions" Message-ID: Content-Type: text/plain; charset=ISO-8859-1; format=flowed On 6/22/06, Felipe Monteiro de Carvalho wrote: -- snip TDOCDocument interface source from FPC 2.0.2 -- TDOMDocument = class(TDOMNode_WithChildren) protected FDocType: TDOMDocumentType; FImplementation: TDOMImplementation; function GetDocumentElement: TDOMElement; public property DocType: TDOMDocumentType read FDocType; property Impl: TDOMImplementation read FImplementation; property DocumentElement: TDOMElement read GetDocumentElement; function CreateElement(const tagName: DOMString): TDOMElement; virtual; function CreateDocumentFragment: TDOMDocumentFragment; function CreateTextNode(const data: DOMString): TDOMText; function CreateComment(const data: DOMString): TDOMComment; function CreateCDATASection(const data: DOMString): TDOMCDATASection; virtual; function CreateProcessingInstruction(const target, data: DOMString): TDOMProcessingInstruction; virtual; function CreateAttribute(const name: DOMString): TDOMAttr; virtual; function CreateEntityReference(const name: DOMString): TDOMEntityReference; virtual; // Free NodeList with TDOMNodeList.Release! function GetElementsByTagName(const tagname: DOMString): TDOMNodeList; // Extensions to DOM interface: constructor Create; function CreateEntity(const data: DOMString): TDOMEntity; end; -- snip -- it's been a bit since i played with the FPC implementation of the XML stuff, but i've done quite a bit of work with DOM in Java. i've included the interface from dom.pp in the 2.0.2 source above for reference. first thing, you need to understand is that TDOMDocument is the "handle" to the DOM. so you need to start with an instance of one of these, either by creating one, or by "loading" an XML document. from there, you ... a) create "nodes" by calling methods on the TDOMDocument (the parent of all nodes). i included some of the specific and more common methods from TDOMDocument below, such as the <CreateElement> function, and the <CreateAttribute> function for instance. -- snip -- function CreateElement(const tagName: DOMString): TDOMElement; virtual; function CreateTextNode(const data: DOMString): TDOMText; function CreateCDATASection(const data: DOMString): TDOMCDATASection; virtual; function CreateAttribute(const name: DOMString): TDOMAttr; virtual; -- snip -- again, you call these on a properly created instance of the TDOMDocument ... because nodes must be "owned" by a document. b) once you have a node, and you've mutated it (set its value etc ...) to your liking, you can then parent it into the XMLDocument by walking the DOM ( getChildren() etc ...) until you get to a node that you want to attach your newly created node to, as a child or sibling or what have you. you create attributes in the same way, by calling methods on the TDOMDocument, which return instances of the attribute class, and then they can be attached to a node in the tree as required, becoming an attribute of that node. you never instantiate nodes and attributes directly, at least not ime. > Felipe Monteiro de Carvalho Tony -- X-SA user ? 0.5.1 is out ! XData 0.1 for X-SA is out ! http://x-plane.dsrts.com ------------------------------ _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal End of fpc-pascal Digest, Vol 22, Issue 11 ******************************************
Michael Van Canneyt
to Pianoman
Pianoman wrote 14 lines
Hi, I'd like to ask whether is it possible to exit program in case of runtime error 202 for example more nicely than with message runtime error 202 at a1d456d5621blablabla For example: writeln('starting to divide:'); writeln(2/0); and I don't want mi program to stop with runtime error but I 'd like to write to screen something like: writeln('program has atempted to divide by zero enter another expression.'); old tp had a special procedure exitproc which allowed to set which code should be executed before terminating in case of run-time error. I mean code which will close opened files or something like that or it could write to logfile the reason of error.

FPC has the same exitproc. See the manuals.

Michael.

Adrian Maier
to Michael Van Canneyt
Michael Van Canneyt wrote 20 lines
On Fri, 23 Jun 2006, Pianoman wrote: > > Hi, I'd like to ask whether is it possible to exit program in case of runtime > error 202 for example more nicely than with message runtime error 202 at > a1d456d5621blablabla > For example: > writeln('starting to divide:'); > writeln(2/0); > and I don't want mi program to stop with runtime error but I 'd like to write > to screen something like: writeln('program has atempted to divide by zero > enter another expression.'); > old tp had a special procedure exitproc which allowed to set which code > should be executed before terminating in case of run-time error. I mean code > which will close opened files or something like that or it could write to > logfile the reason of error. FPC has the same exitproc. See the manuals.

Or, you could use exceptions :

program A;
uses sysutils;
var x:integer;
begin
    x:=0;
    try
        writeln('attempting to divide by zero:');
        writeln(2/x);
        writeln('this line will not be displayed');
    except on E : Exception do
        writeln('Friendly error message  : ',e.message);
    end;
    writeln(' End of program. ');
end.

This way, the program will in fact not anything nasty happens between 'try' and 'except', it will execute the code written in the except clause. Then, the program continues normally.

Cheers,
Adrian Maier

Tony Pelton
to Pianoman: Hi, I'd like to ask whether is it possible to exit program in case of runtime error 202…

please trim your posts.

thanks,
Tony

Pianoman wrote 16 lines
Hi, I'd like to ask whether is it possible to exit program in case of runtime error 202 for example more nicely than with message runtime error 202 at a1d456d5621blablabla For example: writeln('starting to divide:'); writeln(2/0); and I don't want mi program to stop with runtime error but I 'd like to write to screen something like: writeln('program has atempted to divide by zero enter another expression.'); old tp had a special procedure exitproc which allowed to set which code should be executed before terminating in case of run-time error. I mean code which will close opened files or something like that or it could write to logfile the reason of error. Thanx in advance Pianoman
A.J. Venter
to Tony Pelton
Tony Pelton wrote
please trim your posts.

Please do not top-post.

Thanks
A.J. :)

Anyway, to answer the original question - look in the miscelaneous section of the contributed units list on www.freepascal.org for unit errormsg, if the link no longer works (I know a lot don't) mail me offlist, I have a copy.

A.J.

"there's nothing as inspirational for a hacker as a cat obscuring a bug by sitting in front of the monitor" - Boudewijn Rempt A.J. Venter Chief Software Architect OpenLab International www.getopenlab.com www.silentcoder.co.za +27 82 726 5103