Re: [fpc-pascal] Empty string

2008-03-07 Thread Damien Gerard
Le Mar 7, 2008 à 3:35 PM, John Coppens a écrit : On Fri, 7 Mar 2008 15:09:36 +0100 Damien Gerard <[EMAIL PROTECTED]> wrote: Consequently, it can not be the same code. Otherwise I understood nothing :) '' is an empty string, _and_ its length is zero (of course). So the compiler is so intelli

Re: [fpc-pascal] Empty string

2008-03-07 Thread John Coppens
On Fri, 7 Mar 2008 15:09:36 +0100 Damien Gerard <[EMAIL PROTECTED]> wrote: > Consequently, it can not be the same code. Otherwise I understood > nothing :) '' is an empty string, _and_ its length is zero (of course). So the compiler is so intelligent as to replace length(s) = 0, or s = '' by t

Re: [fpc-pascal] Empty string

2008-03-07 Thread Jonas Maebe
On 07 Mar 2008, at 15:09, Damien Gerard wrote: Le Mar 7, 2008 à 2:54 PM, Jonas Maebe a écrit : On 03 Mar 2008, at 17:16, Damien Gerard wrote: In any programs, a lot of tests on empty strings are made. The following made the work : if Length(s) <> 0 then ... or if s <> '' then ... In a lot

Re: [fpc-pascal] Empty string

2008-03-07 Thread Damien Gerard
Le Mar 7, 2008 à 2:54 PM, Jonas Maebe a écrit : On 03 Mar 2008, at 17:16, Damien Gerard wrote: In any programs, a lot of tests on empty strings are made. The following made the work : if Length(s) <> 0 then ... or if s <> '' then ... In a lot of cases, the real length is no needed, just to

Re: [fpc-pascal] Empty string

2008-03-07 Thread Jonas Maebe
On 03 Mar 2008, at 17:16, Damien Gerard wrote: In any programs, a lot of tests on empty strings are made. The following made the work : if Length(s) <> 0 then ... or if s <> '' then ... In a lot of cases, the real length is no needed, just to know if the string is empty or not. That is wha

Re: [fpc-pascal] Empty string

2008-03-07 Thread Damien Gerard
Le Mar 3, 2008 à 5:22 PM, ik a écrit : Doesn't FillChar/Word/Byte works for you ? I don't think any of them made my purpose. Ido On Mon, Mar 3, 2008 at 6:16 PM, Damien Gerard <[EMAIL PROTECTED]> wrote: In any programs, a lot of tests on empty strings are made. The following made the w

Re: [fpc-pascal] Empty string

2008-03-06 Thread Flávio Etrusco
To the OP: are you using the AnsiString as a buffer (that contains "several" strings)? Otherwise, using "MyString <> '' " would do because #0 is only valid as terminator in UTF-8 too. BTW, IIRC Delphi would generate faster code for the above construction instead of "Length(MyString) <> 0" because

Re: [fpc-pascal] Empty string

2008-03-06 Thread Gene Buckle
I thought string should be accessed from 1 not 0 for compatibility. And it is what I am doing. for i := 1 to length(s) do ... so I am not sure that using s[0] is safe If memory serves, the [0] element was originally used to hold a byte that was equivalent to the string length. This was in t

Re: [fpc-pascal] Empty string

2008-03-06 Thread Damien Gerard
Le Mar 6, 2008 à 5:26 PM, Lucas Vasconcelos a écrit : You can try access a UTF8String lika a array. So, you can replace your test by if mystringvar[0] <> '' then ... I thought string should be accessed from 1 not 0 for compatibility. And it is what I am doing. for i := 1 to length(s) do

Re: [fpc-pascal] Empty string

2008-03-06 Thread Lucas Vasconcelos
You can try access a UTF8String lika a array. So, you can replace your test by if mystringvar[0] <> '' then ... -- Lucas Vasconcelos ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Empty string

2008-03-03 Thread ik
Doesn't FillChar/Word/Byte works for you ? Ido On Mon, Mar 3, 2008 at 6:16 PM, Damien Gerard <[EMAIL PROTECTED]> wrote: > > In any programs, a lot of tests on empty strings are made. > The following made the work : > if Length(s) <> 0 then ... > or > if s <> '' then ... > > In a lot of case

[fpc-pascal] Empty string

2008-03-03 Thread Damien Gerard
In any programs, a lot of tests on empty strings are made. The following made the work : if Length(s) <> 0 then ... or if s <> '' then ... In a lot of cases, the real length is no needed, just to know if the string is empty or not. I am mainly using UTF8String so strings with leading zero. Ju