ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Help with Delphi Console Keypress

<< < (2/2)

tranglos:

BTW - Can you tell me why any string def I use will not allow more then 255 chars?  This even happens when I declare the following...

var
      Longstring: AnsiString;

It's supposed to take 2GB, but I keep getting the error saying it can only have 255?  Weird.
-Farmsteader (December 19, 2006, 05:31 PM)
--- End quote ---

When you declare a var as AnsiString in Delphi, you get the old-style statically allocated string with max length of 255. It's the same as saying
var
 myStr : string[255];

What you need is
var
 myStr : string;


Also check in Compiler options that "Huge strings" is enabled - it should be on by default, but do verify. If this define is disabled, the above declaration will still give you a 255-char string.

CodeTRUCKER:
Thank you.  I will give it a try and get back.

mouser:
maybe you can tell us more about the "error" you are getting, to help us help you figure out what it is.

CodeTRUCKER:
I can't get past the 255 error.  Like I said, weird.  Frankly at this point I may have to punt and press on with my old VB5.  I know that pretty well, but I was hoping to get my feet into Delphi.  Well, maybe later I can try again.  I can't wait too long, though.  My trial license of Turbo Delphi is only good for 98 more years! :P  Thanks to All for the help.

tranglos:
Correction, I wasn't remembering clearly:

When you declare a var as AnsiString in Delphi, you get the old-style statically allocated string with max length of 255.
-tranglos (December 20, 2006, 09:33 AM)
--- End quote ---

The above is wrong. Here's what really happens: when you declare a var as AnsiString, you do get the "huge" string variety. This does not depend on the "Huge strings" compiler switch, since you're explicitly asking for one. The compiler switch only affects declarations of "var s : string;"

But as mouser said, please give a bit more info on your code and the specific error.

Navigation

[0] Message Index

[*] Previous page

Go to full version