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

2016-02-12 Thread Marco van de Voort
On Thu, Feb 11, 2016 at 11:08:12AM +0100, Michalis Kamburelis wrote:
> Hm, I admit I simply didn't know about them long time ago, when creating
> file_to_pascal_xxx utilities in PasDoc:)
> 
> Looking at them now:
> 
> 1. They both have quite longer code than our simple
> file_to_pascal_string.dpr / file_to_pascal_data.dpr...
> 
>   In particular data2inc wants to do much more (being able to process a
> special file format like data2inc.exm). Although it can do the simple
> thing when invoked with -b option.

Data2inc is the result of integration of several such programs and is quite
old (late nineties) because they shared many routines (this was all before
strutils and hex/bin/oct functionality in inttostr etc existed). Yes the
bulk of the code is for other things, but I always used it for the straight
case.

IIRC Michael didn't know it, so he wrote bin2obj.


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-12 Thread Michael Van Canneyt



On Fri, 12 Feb 2016, Marco van de Voort wrote:


On Thu, Feb 11, 2016 at 11:08:12AM +0100, Michalis Kamburelis wrote:

Hm, I admit I simply didn't know about them long time ago, when creating
file_to_pascal_xxx utilities in PasDoc:)

Looking at them now:

1. They both have quite longer code than our simple
file_to_pascal_string.dpr / file_to_pascal_data.dpr...

  In particular data2inc wants to do much more (being able to process a
special file format like data2inc.exm). Although it can do the simple
thing when invoked with -b option.


Data2inc is the result of integration of several such programs and is quite
old (late nineties) because they shared many routines (this was all before
strutils and hex/bin/oct functionality in inttostr etc existed). Yes the
bulk of the code is for other things, but I always used it for the straight
case.

IIRC Michael didn't know it, so he wrote bin2obj.


Exactly.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-11 Thread Michalis Kamburelis
Marco van de Voort wrote:
> On Wed, Feb 03, 2016 at 07:07:46AM +0100, Michalis Kamburelis wrote:
>>
>> 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.
> 
> Kind of redundant if two such tools come with FPC (data2inc and bin2obj)
> 

Hm, I admit I simply didn't know about them long time ago, when creating
file_to_pascal_xxx utilities in PasDoc:)

Looking at them now:

1. They both have quite longer code than our simple
file_to_pascal_string.dpr / file_to_pascal_data.dpr...

  In particular data2inc wants to do much more (being able to process a
special file format like data2inc.exm). Although it can do the simple
thing when invoked with -b option.

  But bin2obj is cool, almost exactly what we need, and could replace
file_to_pascal_string and file_to_pascal_data indeed.

2. However, neither of them produces a string with line endings
expressed as LineEnding constant (so it's OS-specific when output). And
we actually like that:) Both bin2obj and data2inc encode the text to a
series of characters, and newlines are expressed by explicit chars (like
#10 when input has Unix line endings).

  But that's a minor thing indeed. If we would know about bin2obj back
then, we would probably use it:)

Thanks!
Michalis

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-11 Thread Michael Van Canneyt



On Thu, 11 Feb 2016, Michalis Kamburelis wrote:


Marco van de Voort wrote:

On Wed, Feb 03, 2016 at 07:07:46AM +0100, Michalis Kamburelis wrote:


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.


Kind of redundant if two such tools come with FPC (data2inc and bin2obj)



Hm, I admit I simply didn't know about them long time ago, when creating
file_to_pascal_xxx utilities in PasDoc:)

Looking at them now:

1. They both have quite longer code than our simple
file_to_pascal_string.dpr / file_to_pascal_data.dpr...

 In particular data2inc wants to do much more (being able to process a
special file format like data2inc.exm). Although it can do the simple
thing when invoked with -b option.

 But bin2obj is cool, almost exactly what we need, and could replace
file_to_pascal_string and file_to_pascal_data indeed.


As the author of bin2obj, I thank you for these words :-)


2. However, neither of them produces a string with line endings
expressed as LineEnding constant (so it's OS-specific when output). And
we actually like that:) Both bin2obj and data2inc encode the text to a
series of characters, and newlines are expressed by explicit chars (like
#10 when input has Unix line endings).

 But that's a minor thing indeed. If we would know about bin2obj back
then, we would probably use it:)


Patches certainly accepted. 
I use bin2obj in production today still...


Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-07 Thread Marco van de Voort
On Wed, Feb 03, 2016 at 07:07:46AM +0100, Michalis Kamburelis wrote:
> 
> 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.

Kind of redundant if two such tools come with FPC (data2inc and bin2obj)

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-03 Thread Luiz Americo Pereira Camara
Thanks for all
Getting time i will do a Lazarus extension

Luiz
Em 3 de fev de 2016 03:13, "Martin Schreiber"  escreveu:

> On Tuesday 02 February 2016 22:33:56 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?
> >
> In MSEide select the text in source editor, RightClick-'Convert to Pascal
> string'. Code is here:
>
> https://gitlab.com/mseide-msegui/mseide-msegui/raw/master/lib/common/kernel/mseformatstr.pas
> Function "stringtopascalstring()".
>
> Martin
>
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-03 Thread vfclists .
On 3 February 2016 at 11:30, Luiz Americo Pereira Camara <
luizameri...@gmail.com> wrote:

> Thanks for all
> Getting time i will do a Lazarus extension
>
> Luiz
> Em 3 de fev de 2016 03:13, "Martin Schreiber" 
> escreveu:
>
>> On Tuesday 02 February 2016 22:33:56 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?
>> >
>> In MSEide select the text in source editor, RightClick-'Convert to Pascal
>> string'. Code is here:
>>
>> https://gitlab.com/mseide-msegui/mseide-msegui/raw/master/lib/common/kernel/mseformatstr.pas
>> Function "stringtopascalstring()".
>>
>> Martin
>>
>>
>
http://forum.lazarus.freepascal.org/index.php/topic,24648.0.html

You may find this lilbrary useful

-- 
Frank Church

===
http://devblog.brahmancreations.com
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-02 Thread Luiz Americo Pereira Camara
2016-02-02 18:40 GMT-03:00 Dmitry Boyarintsev :

> On Tue, Feb 2, 2016 at 4:33 PM, Luiz Americo Pereira Camara <
> luizameri...@gmail.com> wrote:
>
>> Hi is there any tool for Lazarus to convert a multi line text (xml
>> snipet, SQL) to a string constant?
>>
>
> Shouldn't there be something already in Lazarus itself that you could use?
>

I dont know. That's why i'm asking


> Back at the time when all resources were pascal string constants?
>
>
>>
>> Currently i'm using the following regular expression
>>
>> http://regexr.com/3cna5
>>
>
> I think it doesn't replace single-quote character (') by doubled
> single-quote character ( '' )
>
>
It's pretty simple if someone can improve it, it would help

Luiz
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-02 Thread Luiz Americo Pereira Camara
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

Luiz
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-02 Thread Bart
On 2/2/16, 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
>

Well, that's a lot shorter than the program I wrote to doo just that.

Bart

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-02 Thread Dmitry Boyarintsev
On Tue, Feb 2, 2016 at 4:33 PM, Luiz Americo Pereira Camara <
luizameri...@gmail.com> wrote:

> Hi is there any tool for Lazarus to convert a multi line text (xml snipet,
> SQL) to a string constant?
>

Shouldn't there be something already in Lazarus itself that you could use?
Back at the time when all resources were pascal string constants?


>
> Currently i'm using the following regular expression
>
> http://regexr.com/3cna5
>

I think it doesn't replace single-quote character (') by doubled
single-quote character ( '' )

thanks,
Dmitry
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-02 Thread Michalis Kamburelis
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


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-02 Thread Martin Schreiber
On Tuesday 02 February 2016 22:33:56 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?
>
In MSEide select the text in source editor, RightClick-'Convert to Pascal 
string'. Code is here:
https://gitlab.com/mseide-msegui/mseide-msegui/raw/master/lib/common/kernel/mseformatstr.pas
Function "stringtopascalstring()".

Martin

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-02 Thread Graeme Geldenhuys
On 2016-02-02 21:33, 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?

Yes, the tiSQLEditor (written for the tiOPF project) can do just that
(and much more of course). It can convert text to the clipboard (in the
case of the application, normally SQL statements, but any text really)
to Object Pascal strings. It can do the reverse too.  You are welcome to
copy the relevant code out of the project and make a small Memo plus one
Button tool, or simply download the latest binary of tiSQLEditor.


http://sourceforge.net/p/tiopf/tiopf_apps/ci/master/tree/tiSQLEditor_fpGUI/

The code is located in the frm_editor.pas unit.


Binaries of tiSQLEditor can be downloaded from here:

   http://sourceforge.net/projects/tiopf/files/Utilities/



Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


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

2016-02-02 Thread Den
I submitted a patch at one point that never got accepted which uses 
{$INCLUDESTRINGFILE filename} and it includes it as a string. So you 
could do:


Const SOME_TEXT = {$INCLUDESTRINGFILE sometext.txt};

- Dennis

On 2016-02-02 03:33 PM, 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


Luiz


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus