Jump to content

Program Transition - Turbo to Free Pascal

- - - - -

  • Please log in to reply
5 replies to this topic

#1
TheKingfish

TheKingfish

    Newbie

  • Members
  • PipPip
  • 12 posts
[FONT=&]I am a total newbie to Free Pascal (2.4.4), using Win98. A longtime Turbo Pascal (4.0) user, I’m attempting to transfer my TP programs for use in FPC. I am wondering if there exists a general guide (TP>>FPC); a list of code differences that I need to know.[/FONT]

[FONT=&]For my very first program/unit, I performed an initial make-compile which generated a number of compiler messages (identifier not found, etc.). This demonstrates there are code differences, although I’m assuming they’re not extensive. I’m thinking if I could first address the broader/generic code differences, in a second-step I could then minimize/address the subsequent compiler messages.[/FONT]

[FONT=&]I could be over-reacting to this first compile. A possible remedy might be to address those messages in a singular systematic-way. In the broader sense, can anyone provide some helpful input here? Thank you.[/FONT]

#2
lespauled

lespauled

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 231 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash
PORTING TURBO PASCAL TO FREE PASCAL

Free Pascal - Porting Turbo Pascal Applications

#3
TheKingfish

TheKingfish

    Newbie

  • Members
  • PipPip
  • 12 posts
[FONT="]Per my last paragraph, I am slugging it out with multiple compiles, correcting items as I go; not unlike typical programming work. This involves almost 1800 lines of code (program + unit), so it feels like my transition TP code is largely working within the FPC domain. I.e., progress is being made. For the present however, I am stopped by a particular compiler-message. The problem line of code is as follows:[/FONT]
[FONT="]FUNCTION Prob;[/FONT]
[FONT="] [/FONT]
[FONT="]It is the lead line of a function; the only function among many procedures within the unit. The message reads as follows:[/FONT]
[FONT="]Syntax error, “:” expected but “;” found[/FONT]
[FONT="] [/FONT]
[FONT="]A trailing semi-colon is the code convention I‘m familiar with here, so I’m baffled. When I replace it with a colon as requested, the compiler then says a semi-colon was expected (???). Is it possible that FPC doesn’t recognize functions, only procedures? Can anyone shine a light? Thank you.[/FONT]

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 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
functions have to specify the return type. I'm guessing that's missing.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
TheKingfish

TheKingfish

    Newbie

  • Members
  • PipPip
  • 12 posts
[FONT="]Thanks to all for your input. As a result, I now have a clean compile. With 2700 lines of code over the main program and two supporting units, I’m over the hump; the door now open to some fruitful future output. Of course, that’s not to say I won’t be back on the forum with some future “inexplicable” stoppage. When/if I do, I know the support mechanism is here.[/FONT]
[FONT="] [/FONT]
[FONT="]As with any forum-derived remedy, the solution is a conglomeration of many varied pieces of advice. One typically digests all that is offered, learns from each, and crafts a rationale. In this case, there was no code difference between TP and FPC. They appear to be identical, as it should be. The essence of my problem, related to function syntax, was that my former TP4 compiler was a bit more lenient; it allowed a looser interpretation. In the end, the FPC compiler was textbook. It ran when the code finally conformed to proper syntax. Again, much thanks for your help.[/FONT]

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 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
I'm glad we could help :)
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users