Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Freepascal and binary files? (Developers)

posted by Rugxulo Homepage, Usono, 21.05.2020, 02:27

> Does anybody know whether is possible to somehow include files with binary
> data into Freepascal sources?
> It would be nice for things like bundled fonts, icons etc.

Not sure what you're asking here. Clearly you know more about (Turbo) Pascal than I do. I feel like I'm telling you what you already know.

Classic Pascal didn't allow including constant data. (EDIT: The only aggregate data allowed by J&W was strings like "const Msg = 'Hello!';".) TP extended the const keyword for initialized (writable) constant data. So just initialize a constant array. (Or is that too tedious? Do you want an automated way? Not sure offhand what tools would simplify that or what other alternatives exist.)

Obviously, if you bundle binary data, it makes the data harder to modify with third-party tools or reuse with other programs. Often people resort to WAD/PAK/ZIP archives to hold multiple files. (Yes, I realize tons of external files is annoying. I also think a super-bloated .EXE is bad, too. Code and data should "mostly" be kept separated.)

There's also a good FPC wiki article on file handling in Pascal with modern Delphi niceties (TStringList, TFileStream, TMemoryStream).

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 269 users online (0 registered, 269 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum