Re: Can't understand why these exceptions occur...
- From: Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@xxxxxxxxxxx>
- Date: Sat, 31 May 2008 16:25:00 -0400
Ikke wrote:
If I add InOutRes := 0 in any of the procedures, I get an error stating that InOutRes is not a variable.
Thanks,
Ikke
What compiler are you using?
I Hope not .NET!
also,
You didn't read carefully as to what I said about
IoResult.
It clears the state after each read.
this means.
If you do this
If Ioresult <> 0 THen WriteLn(IoResult), it'll always
be 0~! becayse the IoResult is a function and clears the internal
state before returning and returns what the state was..
If you access it again, like in your writeln, it will also be
0 because it's been cleared.!
you do this.
If IoResult <> 0 Then WriteLn('something wrong at Line what ever');
because after this, IoResult access will = 0 until the next failed
Pascal IO function.
It's a one shot deal!
If you don't have InOutRes to directly set it at the start.
then try this.
IoResult;
if its a proper function, it should just simply execute and just
through away the return value as it clears the internal value.
Make sure you enable your "extended syntax" option in the compiler.
if you have it. That'll let you call functions as procedures that
ignore the return value and not complain about it not being assigned to
something .
Like a VOID function in C/C++
If you want display the actual error code, in combination of how you
did it..
do this
Var
Inoutres:integer;
some where in code after a check should be performed.
InOutres := ioResult;
if InoutRes <> 0 then Writeln(InoutRes);
etc..
Or Do this , write a log Error Log Function...
Procedure IoErrorLog(Var LineNUmber:Integer);
Var
InoutRes:Integer;
begin
InoutRes := IoResult;
If INoutRes <> 0 then
WriteLn('IO error at Line #:',LineNumber');
End;
then you simple do this in your code
IoErrorLog(LineNumber?);
etc..
Just remember , your Pascal file code will not function correctly
if there is a lingering error.
http://webpages.charter.net/jamie_5"
.
- Follow-Ups:
- References:
- Can't understand why these exceptions occur...
- From: Ikke
- Re: Can't understand why these exceptions occur...
- From: Skybuck Flying
- Re: Can't understand why these exceptions occur...
- From: Jamie
- Re: Can't understand why these exceptions occur...
- From: Ikke
- Re: Can't understand why these exceptions occur...
- From: Jamie
- Re: Can't understand why these exceptions occur...
- From: Ikke
- Re: Can't understand why these exceptions occur...
- From: Jamie
- Re: Can't understand why these exceptions occur...
- From: Ikke
- Can't understand why these exceptions occur...
- Prev by Date: Re: Can't understand why these exceptions occur...
- Next by Date: Re: Can't understand why these exceptions occur...
- Previous by thread: Re: Can't understand why these exceptions occur...
- Next by thread: Re: Can't understand why these exceptions occur...
- Index(es):
Relevant Pages
|