Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

[TurboPascal, Dev-Pas, FreePascal] problem with longint and unexpected end of file

pascal

  • Please log in to reply
15 replies to this topic

#1 johnyjj2

johnyjj2

    CC Newcomer

  • Just Joined
  • PipPip
  • 23 posts

Posted 03 August 2009 - 02:27 AM

Hello!

I was looking for the answer here but I couldn't find: h ttp://w ww.freepascal.org/port.var -> Free Pascal - Porting Turbo Pascal Applications.

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!
  • 0

#2 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 03 August 2009 - 05:26 AM

end of file shall be End. I don't know if you can have that space there.
otherwise, you often miss an End for something else, so the End. comes too early.
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#3 johnyjj2

johnyjj2

    CC Newcomer

  • Just Joined
  • PipPip
  • 23 posts

Posted 03 August 2009 - 05:32 AM

Thanks!
I corrected this error and now I've got other problem. There were some labels which names begin with digit so I changes label 200 into label lab200.

Now I've got the following 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\program\trc.pas
trc.pas(1,2) Warning: Unsupported switch $N
trc.pas(401,5) Note: Local variable EM1 not used
trc.pas(882,1) Error: Label used but not defined LAB200
trc.pas(1749,11) Fatal: Syntax error, identifier expected but LIBRARY found
It is weird because in the line 733 I've got now:
label lab200;
Lines 881 & 882 are as follows:
window(1,1,80,25); ClrScr;
end;

About the last one error:
Line 1749 contains:
procedure library;

Greetings!

Edited by johnyjj2, 07 August 2009 - 12:55 AM.
+1749

  • 0

#4 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 03 August 2009 - 07:59 AM

Labels have to be defined in the form as well as the code, or else they have to be in the var list and created dynamically.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#5 johnyjj2

johnyjj2

    CC Newcomer

  • Just Joined
  • PipPip
  • 23 posts

Posted 04 August 2009 - 12:34 AM

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\program\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\program\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\program\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\program\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\program\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

Greetings!

Edited by johnyjj2, 07 August 2009 - 12:54 AM.

  • 0

#6 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 04 August 2009 - 06:14 AM

Oh. Goto is evil. Don't use it. You should be using while loops, etc here.

I think the problem really comes down the a problem with poor programming. Function calls, loops, etc are the way to handle the types of things you're doing. There may be compatibility directives you can pass to the compilers to get them to act like TP5.5, but my sense is the code is in desperate need of review/reworking.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#7 johnyjj2

johnyjj2

    CC Newcomer

  • Just Joined
  • PipPip
  • 23 posts

Posted 04 August 2009 - 11:55 PM

Thanks for your reply. It is not my code but something what was written in 1991 and now I was asked to recompile it in XP and later change interface. At this moment I am in that first stage i.e. I cannot compile it :D. This program contains about 3000 of lines in two PAS files and performs some sophisticated maths calculations so I'd like to make as little changes as possible. On the other hand it wasn't my code and I know nothing about the aim of this program - I can see how it works and what it is for after recompiling it :).
Greetings!
  • 0

#8 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 05 August 2009 - 05:57 AM

You can probably still find TurboPascal 5.5 for free, and get it running under DOSBox. My guess, though, is that you need to look at your compiler options for the three compilers you're trying.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#9 johnyjj2

johnyjj2

    CC Newcomer

  • Just Joined
  • PipPip
  • 23 posts

Posted 07 August 2009 - 02:14 AM

Thanks!
I downloaded and installed DOSBox & Turbo Pascal 7.0 on it. I tried to compile my program on TP7.0 but there is weird problem. I open trc.pas, press F9 (Make) and see "Error 15: File not found (CDF.TPU)" in the window "\PROG\TRC.PAS". I check and there exists file CDF.TPU in the directory C:\dosprog\prog where on DOSBox I emulate disc C by command "mount c c:\dosprog\".
Greetings!

Edited by johnyjj2, 07 August 2009 - 05:38 AM.

  • 0

#10 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 07 August 2009 - 06:03 AM

Within TP7 under DOSBox, can you open the file where it expects to find it?
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#11 johnyjj2

johnyjj2

    CC Newcomer

  • Just Joined
  • PipPip
  • 23 posts

Posted 10 August 2009 - 02:00 AM

Yes, it does. I moved the whole project from C:\PROG to C:\TP7\PROG but it didn't help. The same problem - I run C:\TP7\BIN\TURBO.EXE, open C:\TP7\PROG\TRC.PAS, compile it (Alt+F9), see the error "Error 15: File not found (CDF.TPU). I escape turbo.exe, type "cd ..\prog", type "dir cdf" and I see "CDF 0", "CDF PAS", "CDF PPU", "CDF TPU".
Greetings!
PS Of course C:\ is in fact not C:\ but C:\dosprog mounted by DOSBox with the command "mount C C:\dosprog\".

Edited by johnyjj2, 10 August 2009 - 02:04 AM.
PS

  • 0

#12 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 10 August 2009 - 06:00 AM

That's odd... you don't have the "." in the filenames?
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/






Also tagged with one or more of these keywords: pascal

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download