Board index » delphi » String is limited to 255 characters.

String is limited to 255 characters.

Example
  var
     strTest: string
...
  strTest := 'sadfasdfa'+
       'sdfasdfasdfa'+
        ....
      'sdfasdfdas';

I got a compiling error "String literals may have at most 255 elements"
for above line. I first reaction was that the variable might be treated
as short string. However, my compiler syntax options is set to Hugh
String. I also tried to declare the strTest as AnsiString but the error
remains. Actually, the very same line worked fine until yesterday. Thank
you for your help!

 

Re:String is limited to 255 characters.


Quote
Sims <s...@fenix2.dol-esa.gov> wrote in message

news:37F3A422.3B944EAF@fenix2.dol-esa.gov...

Quote
> I got a compiling error "String literals may have at most 255 elements"

This is a compiler limit.  To work around it, try this:

 strTest := 'sadfasdfa ....';
 strTest := strTest+'sdfasdfasdfa ...';

instead of

  strTest := 'sadfasdfa ....'+'sdfasdfasdfa ...';

--
Ernie Deel, EFD Systems
-------------------------------------------------
Gravity ... not just a good idea, it's the law.

Quote
> Example
>   var
>      strTest: string
> ...
>   strTest := 'sadfasdfa'+
>        'sdfasdfasdfa'+
>         ....
>       'sdfasdfdas';

> for above line. I first reaction was that the variable might be treated
> as short string. However, my compiler syntax options is set to Hugh
> String. I also tried to declare the strTest as AnsiString but the error
> remains. Actually, the very same line worked fine until yesterday. Thank
> you for your help!

Re:String is limited to 255 characters.


That was exactly that I did. Would D5 do anything about it? Thank you very
much for your valuable input.
Quote
Ernie Deel wrote:
> Sims <s...@fenix2.dol-esa.gov> wrote in message
> news:37F3A422.3B944EAF@fenix2.dol-esa.gov...
> > I got a compiling error "String literals may have at most 255 elements"

> This is a compiler limit.  To work around it, try this:

>  strTest := 'sadfasdfa ....';
>  strTest := strTest+'sdfasdfasdfa ...';

> instead of

>   strTest := 'sadfasdfa ....'+'sdfasdfasdfa ...';

> --
> Ernie Deel, EFD Systems
> -------------------------------------------------
> Gravity ... not just a good idea, it's the law.

> > Example
> >   var
> >      strTest: string
> > ...
> >   strTest := 'sadfasdfa'+
> >        'sdfasdfasdfa'+
> >         ....
> >       'sdfasdfdas';

> > for above line. I first reaction was that the variable might be treated
> > as short string. However, my compiler syntax options is set to Hugh
> > String. I also tried to declare the strTest as AnsiString but the error
> > remains. Actually, the very same line worked fine until yesterday. Thank
> > you for your help!

Re:String is limited to 255 characters.


There is no change in D5.

Bill

--

Bill Todd - TeamB
(TeamB cannot respond to questions received via email)

Other Threads