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

Marc Santhoff M.Santhoff at web.de
Wed Feb 3 01:39:54 CET 2016


On Di, 2016-02-02 at 18:33 -0300, 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

I have no solution but want to point out that for embedded programming
such a tool would be helpful, too.

I know "cruom" from NutOS doing the job written in and generating C
code. It's purpose is to create constants for using as a simple file
system. It is called naming a directory and writes to stdout all files
in it.

Example of usage and output:

<console>

$ mkdir ctest
$ echo "var" > ctest/file1.pas
$ echo "  i: integer;" >> ctest/file1.pas

$ /usr/local/avr/ethernut-4.8.3/bin/crurom ctest
/*
 * This file is automatically created by crurom 1.3.2
 */
#include <fs/uromfs.h>

/*
 * File entry 1: file1.pas
 */
prog_char file1data[] = {
0x76,0x61,0x72,0x0a,0x20,0x20,0x69,0x3a,0x20,0x69,0x6e,0x74,0x65,0x67,0x65,0x72,0x3b,0x0a,
};

prog_char file1name[] = "file1.pas";

static ROMENTRY file1entry = { 0, (prog_char *)file1name, 18, (prog_char *)file1data };

ROMENTRY *romEntryList = &file1entry;

</console>

An example of usage is there:
http://www.ethernut.de/nutwiki/Reading_UROM_Files


-- 
Marc Santhoff <M.Santhoff at web.de>





More information about the Lazarus mailing list