Re: [Lazarus] Tool to convert a multiline text to a pascal string constant
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
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
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
Re: [Lazarus] Tool to convert a multiline text to a pascal string constant
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: $ 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 /* * 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; An example of usage is there: http://www.ethernut.de/nutwiki/Reading_UROM_Files -- Marc Santhoff -- ___ 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
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
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 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
Re: [Lazarus] Tool to convert a multiline text to a pascal string constant
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
[Lazarus] Tool to convert a multiline text to a pascal string constant
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] Debian (Sid): fpc 3.0.0+dfsg-2 cannot compile lazarus trunc
On Mon, 1 Feb 2016 20:39:59 +0100, you wrote: >Am 01.02.2016 um 18:47 schrieb Mattias Gaertner: >> On Mon, 1 Feb 2016 18:20:59 +0100 >> John Landmesser wrote: >> >> Is this the new FPC 3.0.0 from Debian unstable? >> >> Mattias >> > >yes it's from unstable ( sid ) I've seen a couple of Debian's fpc "upgrades" break Lazarus, but I'm running Jessie (stable). All I did to fix the problem was disallow upgrades to either Lazarus or fpc, and I download the .debs from SourceForge. I do also have an installation from getlazarus that's working just fine once someone sent me a replacement script, that's fpc 3.1.1 and Lazarus 1.7. Once again, though, this is Jessie, not sid. Brian. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus