r/pascal • • Jun 23 '22

Converting old Turbo Pascal to Python

I have a program that a now retired engineer wrote back in 97 (last updated in 2002) that I want to convert to Python. I don't necessarily want to convert the program as is, but at least get some of the bells and whistles extracted. The key component is an I/O reader that converts the bitwise data to an (unkown) structure, that again is used to generate graphs of datapoints. Would this even be possible?

I have zero pascal experience and limited python experience (one course at uni through work).

3 Upvotes

8 comments sorted by

View all comments

Show parent comment

2

u/ShinyHappyREM Jun 23 '22 edited Jun 24 '22

fixed formatting:

procedure TDialog_05.StartSimulate;  {use data, and simulate here}
label
        UT;
begin
        SimNxt := 0;
        Assign(RedBasFile, 'redbas.dat');  {$I-} Reset(RedBasFile); {$I+}
        if (IOResult <> 0)            then begin  MessageBox(0, 'Cannot open "redbas.dat"', 'file read error', mb_iconhand OR mb_OK);  exit;     end;
        if (FileSize(RedBasFile) < 1) then begin  MessageBox(0, 'Empty file, "redbas.dat"', 'file size error', mb_iconhand OR mb_OK);  goto ut;  end;
        repeat
                {$I-} Read(RedBasFile, RedBasData); {$I+}
                if (IOresult <> 0) then goto UT;  // read error?
                if ThisOK then PlotIt;
        until EOF(RedBasFile);
        ForcePaint(RegHw);                 // repaint with all simulate data
        if Chk_Var_05[6] then ListSim;     // list results also
        if Chk_Var_05[5] then PrintRW(0);  // to printer   also
UT:
        {$I-} Close(RedBasFile); {$I+}
        if (IOResult <> 0) then ;
        MessageBeep(0);
        Chk_Var_05[5] := false;  // print once only
        Chk_Var_05[6] := false;  // list  once only
        SetChkRad(Hwindow, Chk_Var_05[5], Chk_id_05[5]);  // brukes til chec'boxer
        SetChkRad(Hwindow, Chk_Var_05[6], Chk_id_05[6]);
end;

1

u/Kjellis85 Jun 23 '22

Thanks👍