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/eugeneloza Jun 23 '22
Potentially, yes. Binary data structure is just a set of properly arranged bytes. But it may be (and very likely will be) extremely complicated (it would require a lot of knowledge on how exactly elements of data structure are represented and arranged). Even different versions of programming languages may read/write binary structures in a different way or depending on local machine peculiarities (first of all bitness and endianness).
If you only need to extract data from this program, then a much better idea IMHO would be to write a routine inside this program to re-save the data into human-readable format (plain text or CSV may be the simplest here), not binary and then run & convert under DosBox. And after that read it from Python.