Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

txt2inc

Shell program to convert any text file content as Pascal quoted string variable

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

txt2inc

Shell program to convert any text file content as Pascal quoted string variable

Requirement

Compilation

Clone this repository and run FreePascal compiler.

pascal
$ fpc txt2inc.pas

Run

pascal
$ ./txt2inc /path/to/input/text/file /path/to/output/file variableName

For example, if content of /path/to/input/text/file is like following

pascal
<html>
<head></head>
<body>
    <a href="link.html">Link</a>
</body>
</html>

Then output file will contain text as below

pascal
variableName : string =
'   <html>' + LineEnding +
'   <head></head>' + LineEnding +
'   <body>' + LineEnding +
'       <a href="link.html">Link</a>' + LineEnding +
'   </body>' + LineEnding +
'   </html>';

Which actually a valid Pascal string variable declaration, which then can be included in Pascal program/unit source code.

pascal
var

    {$INCLUDE output.inc}

Credit

Original author is irfanbagus

Multiline string constant discussion