Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
[TurboPascal, Dev-Pas] problem with longint and unexpected end of file Posted by johnyjj2 on 3 Aug 2009 at 3:22 AM
Hello!

I was looking for the answer here but I couldn't find: http://www.freepascal.org/port.var .

I've got old code in Turbo Pascal and I try to run it on Dev-Pascal 1.9.2. (I also tried Lazarus application, but there was "Error. Project raised exception class 'External: SIGSEGV'.").

Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Win32 for i386
Compiling f:\intern\26turb~1\program\main1.pas
main1.pas(1,2) Warning: Unsupported switch $N
Compiling main2.pas
main2.pas(1,2) Warning: Unsupported switch $N
main2.pas(308,15) Error: call by var parameters have to match exactly: Got LONGINT expected SMALLINT
main2.pas(645,76) Warning: Comment level 2 found
main2.pas(843,3) Warning: Comment level 2 found
main2.pas(643,2) Fatal: Unexpected end of file


I look at these two lines:
308: InitGraph(ster,tryb,path);
52: ster:integer=VGA;


I changes line 52.
52: ster:smallint=VGA;

I also tried:
52: ster:shortint=VGA;

But neither of them can help and there's all the time the same error: Got LONGINT expected SMALLINT.

And the other thing, that is "unexpected end of file".
End of the file is as follows:
  Resume
  end
end;


end .


How to get rid of those two errors?

Greetings!
Report
Re: [TurboPascal, ev-Pas] problem with ... Posted by Atex on 3 Aug 2009 at 7:58 PM
Did you include {$mode tp} and {$asmmode intel} as first lines in your code ? Also check the comments, most likely that's what causing the unexpected end of file error. Doesn't hurt to upgrade to the latest FP as well.
Report
Re: [TurboPascal, ev-Pas] problem with ... Posted by johnyjj2 on 4 Aug 2009 at 3:18 AM
Hello!

I got rid of some problems with changing code from Turbo Pascal (from eighteen years ago) to Free Pascal (Dev-Pascal). Those problems were changing integer into smallint and erasing nested comments.

Now I've got problems with labels.

All results of "200", "label" and "goto":
69:   menu1[4]:='Library       ';
732: procedure axesimu;
733: label 0200;
744: case vv of
747:  3: Goto 0200;
881: 200: window(1,1,80,25); ClrScr;
884:  procedure TwoAxles;
885:label 100;
1025:    if (zn='N') or (zn='n') then goto 100;
1752: procedure library;
1871:  4: library;


Without any changes:
Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Win32 for i386
Compiling f:\dev-pas\company\02trc~1.pas
02trc~1.pas(1,2) Warning: Unsupported switch $N
02trc~1.pas(401,5) Note: Local variable EM1 not used
02trc~1.pas(881,1) Error: Identifier not found 200
02trc~1.pas(881,4) Error: Illegal expression
02trc~1.pas(881,4) Fatal: Syntax error, ; expected but : found


After adding to the second line {$GOTO ON}
Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Win32 for i386
Compiling f:\dev-pas\company\02trc~1.pas
02trc~1.pas(1,2) Warning: Unsupported switch $N
02trc~1.pas(402,5) Note: Local variable EM1 not used
02trc~1.pas(882,1) Error: Identifier not found 200
02trc~1.pas(882,4) Error: Illegal expression
02trc~1.pas(882,4) Fatal: Syntax error, ; expected but : found


After changing from
200: window(1,1,80,25); ClrScr;

to
window(1,1,80,25); ClrScr;

compilation errors:
Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Win32 for i386
Compiling f:\dev-pas\company\02trc~1.pas
02trc~1.pas(1,2) Warning: Unsupported switch $N
02trc~1.pas(402,5) Note: Local variable EM1 not used
02trc~1.pas(883,1) Error: Label used but not defined 0200
02trc~1.pas(1750,11) Fatal: Syntax error, identifier expected but LIBRARY found


After changing into:
 label 200; window(1,1,80,25); ClrScr;

errors:
Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Win32 for i386
Compiling f:\dev-pas\company\02trc~1.pas
02trc~1.pas(1,2) Warning: Unsupported switch $N
02trc~1.pas(402,5) Note: Local variable EM1 not used
02trc~1.pas(882,8) Error: Illegal expression
02trc~1.pas(882,8) Error: Illegal expression
02trc~1.pas(882,8) Fatal: Syntax error, ; expected but ordinal const found


After changing into
window(1,1,80,25); ClrScr;

And changing 734:
label 0200;
into
label lab200;
And 748:
3: Goto 0200;
into
3: Goto lab200;
And 886:
label 100;
into
label lab100;
And 1026:
if (zn='N') or (zn='n') then goto 100;
into
if (zn='N') or (zn='n') then goto lab100;
And 1069
100: ClrScr;
into
label lab100; ClrScr;
The errors:
Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Win32 for i386
Compiling f:\dev-pas\company\02trc~1.pas
02trc~1.pas(1,2) Warning: Unsupported switch $N
02trc~1.pas(402,5) Note: Local variable EM1 not used
02trc~1.pas(883,1) Error: Label used but not defined LAB200
02trc~1.pas(1069,7) Error: Illegal expression
02trc~1.pas(1069,7) Error: Illegal expression
02trc~1.pas(1069,7) Fatal: Syntax error, ; expected but identifier LAB100 found


The last one thing which I tried was to add at the beginning of the code three things (on the file with no changes):
{$GOTO ON}
{$mode tp}
{$asmmode intel}

And errors:
Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Win32 for i386
Compiling f:\dev-pas\company\trc.pas
trc.pas(1,2) Warning: Unsupported switch $N
trc.pas(404,5) Note: Local variable EM1 not used
trc.pas(885,1) Error: Label used but not defined 0200
trc.pas(1752,11) Fatal: Syntax error, identifier expected but LIBRARY found


Greetings!
Report
Re: [TurboPascal, ev-Pas] problem with ... Posted by Atex on 4 Aug 2009 at 8:13 PM
An upgrade to the latest FP will solve the $N switch issue, not important at all since all newer CPU's have numeric co-processor. Labels must be declared before used, eg.
program xyz;

label _name_; { <-- declaration, once per label }

begin
 {...}
 _name_: { <-- doesn't need the label word}
 {...}
 goto _name_; { jump to label }
 {...}
end.
As for the last error, IMO the naming could be the cause for the conflict...



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.