Re: [fpc-pascal] CSV via PCRE

2007-11-10 Thread Graeme Geldenhuys
OK, while we are busy with show-and-tell... Then have a look at my token library implementation. http://tinyurl.com/395vgp * It's based on a Infinite State Machine. * No external units required. * Allows multiple separators (user selectable) between tokens. * Allows for user selectable sepera

Re: [fpc-pascal] CSV via PCRE

2007-11-10 Thread Micha Nelissen
Graeme Geldenhuys wrote: > OK, while we are busy with show-and-tell... Then have a look at my > token library implementation. You've implemented some kind of 'cut'. But grep is also very useful (and more often used in a shell, at least by me). Micha ___

[fpc-pascal] Help making code unicode capable

2007-11-10 Thread Felipe Monteiro de Carvalho
Hello, I have a small piece of code on LCL which I have found hard to convert to unicode: lpStrFilter := StrAlloc(Length(Filter)+1); StrPCopy(lpStrFilter, Filter); on win32wsdialogs.pp lpStrFilter is a member on the LPOPENFILENAME winapi structure. Having a win9x version is trivial

Re: [fpc-pascal] Help making code unicode capable

2007-11-10 Thread Jonas Maebe
On 10 Nov 2007, at 15:08, Felipe Monteiro de Carvalho wrote: Having a win9x version is trivial, but having a version where we put a PWideChar into lpStrFilter looks hard... lpStrFilter := StrAlloc(Length(Filter)+1); StrPCopy(lpStrFilter, Utf8ToAnsi(Filter)); I tryed this as unicode

Re: [fpc-pascal] Help making code unicode capable

2007-11-10 Thread Marco van de Voort
> On 10 Nov 2007, at 15:08, Felipe Monteiro de Carvalho wrote: > > > Having a win9x version is trivial, but having a version where we put a > > PWideChar into lpStrFilter looks hard... > > > > lpStrFilter := StrAlloc(Length(Filter)+1); > > StrPCopy(lpStrFilter, Utf8ToAnsi(Filter)); > > >

Re: [fpc-pascal] Help making code unicode capable

2007-11-10 Thread Felipe Monteiro de Carvalho
> utf8decode returns string I assume? It returns WideString. Is there a function to manually alloc a widestring like StrAlloc? -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailma

Re: [fpc-pascal] Help making code unicode capable

2007-11-10 Thread Jonas Maebe
On 10 Nov 2007, at 15:24, Felipe Monteiro de Carvalho wrote: utf8decode returns string I assume? It returns WideString. Is there a function to manually alloc a widestring like StrAlloc? Assign it to a variable of the type widestring. If you cannot this variable in scope the whole time, yo

Re: [fpc-pascal] Help making code unicode capable

2007-11-10 Thread Felipe Monteiro de Carvalho
Thanks, I arrived at this: var FilterBuffer: WideString; ... FilterBuffer := Utf8Decode(Filter); lpStrFilter := GetMem(Length(FilterBuffer) * 2 + 2); Move(FilterBuffer, lpStrFilter, Length(FilterBuffer) * 2 + 2); But now it crashes when loading the dialog =/ any ideas? than

Re: [fpc-pascal] Help making code unicode capable

2007-11-10 Thread Mattias Gaertner
On Sat, 10 Nov 2007 15:44:54 +0100 "Felipe Monteiro de Carvalho" <[EMAIL PROTECTED]> wrote: > Thanks, I arrived at this: > > var > FilterBuffer: WideString; > ... > > FilterBuffer := Utf8Decode(Filter); > lpStrFilter := GetMem(Length(FilterBuffer) * 2 + 2); > Move(FilterBuffe

[fpc-pascal] More help with unicode

2007-11-10 Thread Felipe Monteiro de Carvalho
Hello, I still have some issues with unicode support =) I am trying to implement unicode support for TMemo, but somehow the solution isn't simple. TMemo will throw a WM_SETTEXT message to when it's text is set, like this: SendMessage(fHandle, WM_SETTEXT, 0, LPARAM(TheText)); Which I tryed t

Re: [fpc-pascal] Help making code unicode capable

2007-11-10 Thread Felipe Monteiro de Carvalho
On Nov 10, 2007 3:54 PM, Mattias Gaertner <[EMAIL PROTECTED]> wrote: >Move(FilterBuffer[0], lpStrFilter^, Length(FilterBuffer) * 2 + > 2); The compiler wisely doesn't allow accessing [0], but: Move(FilterBuffer[1], lpStrFilter^, Length(FilterBuffer) * 2 + 2); Seams to work perfectl

Re: [fpc-pascal] More help with unicode

2007-11-10 Thread Jonas Maebe
On 10 Nov 2007, at 16:23, Felipe Monteiro de Carvalho wrote: Which I tryed to convert to: if UnicodeEnabledOS then SendMessage(fHandle, WM_SETTEXT, 0, LPARAM(PWideChar(Utf8Decode(TheText else SendMessage(fHandle, WM_SETTEXT, 0, LPARAM(PChar(Utf8ToAnsi(TheText; But t

[fpc-pascal] outportb

2007-11-10 Thread Mihai
Hello all, I am new with FPC and I am trying something nasty on Linux SO (some lp0 output command by data bits). Is there any chance to use FPC on Linux to handle parallel port data bits as in outportb[$378]:=32; ? Thank you very much, Mihai ___ fpc-pas

Re: [fpc-pascal] More help with unicode

2007-11-10 Thread Felipe Monteiro de Carvalho
On Nov 10, 2007 4:30 PM, Jonas Maebe <[EMAIL PROTECTED]> wrote: > You're making the same error which Marco pointed out earlier: > Utf8Decode returns a (reference counted) widestring, but you are not > assigning it to anything so it ends up in a (reusable) temp location. > As soon as the next tempor

Re: [fpc-pascal] outportb

2007-11-10 Thread Felipe Monteiro de Carvalho
On Nov 10, 2007 4:30 PM, Mihai <[EMAIL PROTECTED]> wrote: > I am new with FPC and I am trying something nasty on Linux > SO (some lp0 output command by data bits). > Is there any chance to use FPC on Linux to handle parallel > port data bits as in outportb[$378]:=32; ? Explained here: http://wiki

Re: [fpc-pascal] outportb

2007-11-10 Thread Marco van de Voort
> On Nov 10, 2007 4:30 PM, Mihai <[EMAIL PROTECTED]> wrote: > > I am new with FPC and I am trying something nasty on Linux > > SO (some lp0 output command by data bits). > > Is there any chance to use FPC on Linux to handle parallel > > port data bits as in outportb[$378]:=32; ? > > Explained here

Re: [fpc-pascal] Help making code unicode capable

2007-11-10 Thread Marc Weustink
Felipe Monteiro de Carvalho wrote: Hello, I have a small piece of code on LCL which I have found hard to convert to unicode: lpStrFilter := StrAlloc(Length(Filter)+1); StrPCopy(lpStrFilter, Filter); There is a big chance that this is an inheritence of the pre 1.0 fpc times. At th

Re: [fpc-pascal] Help making code unicode capable

2007-11-10 Thread Marc Weustink
Mattias Gaertner wrote: On Sat, 10 Nov 2007 15:44:54 +0100 "Felipe Monteiro de Carvalho" <[EMAIL PROTECTED]> wrote: Thanks, I arrived at this: var FilterBuffer: WideString; ... FilterBuffer := Utf8Decode(Filter); lpStrFilter := GetMem(Length(FilterBuffer) * 2 + 2); Move(Fi

Re: [fpc-pascal] More help with unicode

2007-11-10 Thread Felipe Monteiro de Carvalho
I now see that I should probably be using SendMessageW, but that didn't make any difference. thanks, -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] outportb

2007-11-10 Thread Mihai
> > On Nov 10, 2007 4:30 PM, Mihai <[EMAIL PROTECTED]> > > wrote: > > > I am new with FPC and I am trying something nasty on > > > Linux SO (some lp0 output command by data bits). > > > Is there any chance to use FPC on Linux to handle > > > parallel port data bits as in outportb[$378]:=32; ? > >

Re: [fpc-pascal] CSV via PCRE

2007-11-10 Thread S. Fisher
--- Graeme Geldenhuys <[EMAIL PROTECTED]> wrote: > OK, while we are busy with show-and-tell... Then have a look at my > token library implementation. > > http://tinyurl.com/395vgp > > Sample Usage: > > tokenizer := TTokens.Create(FieldSpecLine, ', ', '"', '"', '\', > tsMul

Re: [fpc-pascal] CSV via PCRE

2007-11-10 Thread Graeme Geldenhuys
On 11/11/2007, S. Fisher <[EMAIL PROTECTED]> wrote: > > That's not a working sample. It has no CSV record to parse. > > Give a working program that we can run with no modifications > whatsoever; parse an actual CSV record; print every field > in the record. That's what my sample did. The code s

[fpc-pascal] regex-dna: finally fast enough?

2007-11-10 Thread S. Fisher
I don't think so, although it's over twice as fast as the last incarnation. One speedup I stole from the Perl program: instead of counting matches for /foo|bar/, count matches for /foo/ and for /bar/. The other speedup is lowercasing the string that is searched instead of requiring the regex engi

Re: [fpc-pascal] CSV via PCRE

2007-11-10 Thread S. Fisher
--- Graeme Geldenhuys <[EMAIL PROTECTED]> wrote: > The code shown in the url below works just fine. Also the usage sample > is all you need to use the tokenizer. Just replace the FieldSpecLine > variable with the content from a CSV file and you are good to go. I > use it as-is in my production c