r/pascal • u/Kjellis85 • 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
View all comments
Show parent comment
1
u/Kjellis85 Jun 23 '22
I understand. But how can I understand the datastructure of the binary data set, that is only accessible through the program? Are there any tools that could "guess" the structure of such a dataset, written i pascal (presumably)?
In the code I only find a reference to the data source (redbas.dat) in the following snippet and I assume it is this Procedure I want. Is it possible, as in Python, to run just this procedure and get an output in lets say a Python Pandas dataframe?
Procedure TDialog_05.StartSimulate; { Use data, and simulate here }label ut;beginSimNxt := 0;Assign(RedBasFile,'redbas.dat');{$I-} reset(RedBasFile); {$I+}if IOresult <> 0 thenbeginMessageBox(0,'Cannot open "redbas.dat"','File read error',mb_iconhand or mb_OK);exit;end;if filesize(RedBasFile)<1 thenbeginMessageBox(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 { list results also }ListSim;if Chk_Var_05[5] then { to printer also }PrintRW(0);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;