FILE_TO_PASCAL_DATA(1)

πŸ“¦ version 1.0.4, in fedora 43, fedora 44

πŸ’– FILE_TO_PASCAL_DATA(1) β€” bestie edition πŸ’–

okay so picture this: you're in the User commands section of the manual (section 1, obviously, iykyk), and you've got a file. and you want that file inside a Pascal program. not linked, not read at runtime β€” embedded. like, baked right in. that's literally what these two little icons do and I'm obsessed. ✨


🌸 NAME 🌸

file_to_pascal_data, file_to_pascal_string β€” the way that they convert files to Pascal source code. no cap. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

file_to_pascal_data INPUT_FILE OUTPUT_FILE
file_to_pascal_string INPUT_FILE OUTPUT_FILE

πŸ’… DESCRIPTION πŸ’…

so here's the tea, bestie: the file_to_pascal_data and file_to_pascal_string programs can be used to convert files to Pascal source code, so you can embed data inside Pascal programs. main character energy fr fr. πŸ‘‘

file_to_pascal_data encodes INPUT_FILE as an Array of Byte, whereas file_to_pascal_string encodes it as a string literal.

two programs, two vibes, same job: get your bytes into a .inc and go πŸ’€

🌈 EXAMPLES 🌈

okay so consider a file containing only the text "Example" (with a newline character at the end) being used as the input. tiny file, huge potential. πŸ“

after converting the input using file_to_pascal_data, the output file can be used like in the following example:

const EmbeddedData: {$INCLUDE output_data.inc};

after including the file, this will evaluate to something like:

const EmbeddedData: array[0..7] of byte = (
    $45, $78, $61, $6D, $70, $6C, $65, $0A
);

look at those eight little bytes. $0A at the end is the newline, she's shy but she's there. πŸ™ˆ

the output generated by file_to_pascal_string can be used in a similar fashion:

const EmbeddedString = {$INCLUDE output_string.inc};

after including the file, this will evaluate to something like:

const EmbeddedString = 'Example' + LineEnding;

see how it kept the newline as LineEnding instead of hardcoding it? that's range, that's taste, that's portability. slay. πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie. you ate. πŸ’–βœ¨πŸ¦‹πŸŒΈ this one's dated 2021-09-22, from the User commands corner of the world β€” go embed something iconic. periodt. πŸ’…

πŸ“¦ where this page comes from