Brain Phrye

code cooking diy fiction personal photos politics reviews tools 


APC to fpc

After my initial research I filed two bugs (35596 and 35597), decided to put graphics aside and tried getting non-graphics programs running.

And I’ve had good success so far. I’ve ported 15 so far.

The fpc compiler has various modes which includes a Turbo Pascal mode. However that’s somewhere around Turbo Pascal 7 - definitely not all the way back to version 3.01a like we were using.

This isn’t a huge stumbling block though. All it means so far is that the run time library isn’t included by default, and that library is broken into different units. All that’s needed is to add a USES directive to the code and it should be fine. USES CRT is the most common addition but the KEYBOARD, PRINTER and SYSUTILS modules have each made a few appearances.

A short, minimal example is a program clearly written to learn recursion:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
PROGRAM WordFind ;
USES CRT;

VAR
  UserWord : String[80] ;
  Count ,
  Score ,
  TotScore : INTEGER ;

PROCEDURE FindLetter (Letter : CHAR ;
                      Place : INTEGER ;
                  VAR TheScore : INTEGER) ;

  VAR
    Number : INTEGER ;

  BEGIN
    IF TheScore <= 180
      THEN BEGIN
             Number := RANDOM(90)+32 ;
             GOTOXY (Place + 2,5) ;
             WRITE (chr(Number)) ;
             IF chr(Number) <> Letter
               THEN BEGIN
                 TheScore := TheScore + 1 ;
                 FindLetter (Letter,Place,TheScore)
               END
           END
      ELSE BEGIN
             GOTOXY (Place + 2,5) ;
             WRITE (' ') ;
             GOTOXY (Place + 2,6) ;
             WRITE ('?')
           END
  END ;

BEGIN
  CLRSCR ;
  WRITE ('Please enter a word: ') ;
  READLN (UserWord) ;
  TotScore := 0 ;
  FOR Count := 1 TO LENGTH (UserWord) DO
    BEGIN
      FindLetter (UserWord[Count],Count,Score) ;
      TotScore := TotScore + Score ;
      Score := 0
    END ;
    GOTOXY (1,8) ;
    WRITELN (TotScore) ;
END.

All I had to add to that was USES CRT.

The graphics side still looks to be complicated with most examples assuming I’m using the GUI IDE Lazarus.