[Lazarus] Tool to convert a multiline text to a pascal string constant

Michalis Kamburelis michalis.kambi at gmail.com
Wed Feb 3 07:07:46 CET 2016


Luiz Americo Pereira Camara wrote:
> Hi is there any tool for Lazarus to convert a multi line text (xml
> snipet, SQL) to a string constant?
> 
> Currently i'm using the following regular expression
> 
> http://regexr.com/3cna5
> 
> If some one knows a better regular expression that handles putting ';'
> instead of '+ LineEnding +' in last line would help also
> 

As part of PasDoc project we have developed simple file_to_pascal_string
utility for this purpose. Just get
http://svn.code.sf.net/p/pasdoc/code/trunk/source/tools/file_to_pascal_string.dpr
and compile it.

Alongside, there's also file_to_pascal_data that converts anything to an
"array [0 .. Xxx] of Byte" (good to include binary data in the same
way). See
http://svn.code.sf.net/p/pasdoc/code/trunk/source/tools/file_to_pascal_data.dpr
. And see http://pasdoc.sipsolutions.net/ for whole PasDoc website and
links to whole SVN and GIT sources.

I'm using these utilities throughout my projects -- PasDoc, Castle Game
Engine, to include text and binary data inside compiled file. (Although
at some point I may migrate to using FPC cross-platform resource files
for similar purpose.)

Regards,
Michalis





More information about the Lazarus mailing list