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!

end . should be end. (remove the space)

Not sure about the first error. Could it be triggered by the $N switch error ? Look for {$N} and remove it (at the top).

Thanks!
I got rid of the first problem - it was because Dev-Pascal treats integer as longint and shortint as integer.
I removed the spacebar before dot. Now it looks like this

Infos;
  Resume
  end
end;
end.

But the error is the same :-(.
Greetings!

OK, I got rid of those two problems. Now I've got new errors to debug :D.

line number 881 contains:

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\main.pas
trc.pas(1,2) Warning: Unsupported switch $N
trc.pas(401,5) Note: Local variable EM1 not used
trc.pas(881,1) Error: Identifier not found 200
trc.pas(881,4) Error: Illegal expression
trc.pas(881,4) Fatal: Syntax error, ; expected but : found

It looks like I cannot use names (or rather numbers - 200) to indicate something in the code which are then reached by goto or something like this. How to get rid of this error :-)?

I tried to erase that

200:

so there was left

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

but it caused other error:

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\main1.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 0200
trc.pas(1749,11) Fatal: Syntax error, identifier expected but LIBRARY found

Greetings!

Correct. Labels must start with a character, not a number. Add a prefix to the 200, like:

label200:

and change the references in the code.

Thanks!
I changed twice in the code 200 into 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\trackal\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;

Greetings!

Whitespace between the keyword end and the period is not significant.

Perhaps you should post more code? It is hard to diagnose what is wrong.

With FPC, you must be sure to have the {$goto on} directive enabled.

I don't think that the $N directive is used in FPC -- the FPC uses native floating-point types -- there is no need to ask for them or emulate them.

All results of "200", "label" and "goto":

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;

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\trackal\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\trackal\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\trackal\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\trackal\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\trackal\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!

Turbo pascal 7.0.
Labels' identifier can be numbers from 0 to 9999,and any name that can be an identifier...
Free Pascal
A label is a name for a location in the source code to which can be jumped from another location
with a Goto statement. Labels can be digit sequences or identifiers.
The -Sg or -Mtp switches must be specified before labels can be used. By default, Free Pascal doesn’t support label and goto statements. The {$GOTO ON} directive can also be used to allow use of labels and the goto statement.

Link:ftp://ftp.freepascal.org/pub/fpc/docs-pdf/ref.pdf

johnyjj2 if you really want help, please post your code.

What you've listed so far is nonsense.

Thanks!
In other words I can use those names like 0200 or 200.
I added {$GOTO ON} but it didn't help.

The -Sg or -Mtp switches must be specified before labels can be used.

I checked that pdf to which you gave me link. There is nothing more written there than what you wrote. I looked for "-Sg" in that file but I couldn't find how to specify those switches. How to do it?
Greetings!

Listen my code!

program solution;
{$GOTO ON}
Label 12,yeep;
Begin
     GoTo 12;
     WriteLn('Hello');{no}
12:Begin
          WriteLn('I''m just jumping to the next goal');{out}
          GoTo yeep;{jumps to the yeep label}
     End;
     WriteLn('Hm....');{no}
yeep:WriteLn('press enter...');{out}
     ReadLn;
End.

I wrote this little program in free pascal 2.2.4.,and it is working!!
I found nothing about the -Sg or -Mtp switches,but DUOAS was right about {$GOTO ON}.
You can set the goto on option in the options/compiler/syntax/Allow LABEL and GOTO

Thank you :-).
I checked settings of Free Pascal compiler and it is set "allow label and goto" in the default configuration. I changed all "0200"s into "200"s and it works, combined with {&GOTO ON}.
Greetings!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.