Lars Fosdal 1792 Posted February 23, 2021 I am not always putting huge strings into constants, but when I am testing a parser I am. Except - Delphi does NOT like string literals longer than 255 chars. It is probably logical, but still annoying. var s: string; begin s := 'string that is 750 chars long'; // compiler barfs with [dcc32 Error] E2056 String literals may have at most 255 elements s := '250 chars' + '250 chars' + '250 chars'; // ok /rant Share this post Link to post
Angus Robertson 574 Posted February 23, 2021 Agreed. annoying when creating SSL certificates as literals to embed in an application. Angus Share this post Link to post
Guest Posted February 23, 2021 7 hours ago, Lars Fosdal said: ... It is probably logical, but still annoying. maybe help you using "AnsiString" definition http://docwiki.embarcadero.com/RADStudio/Sydney/en/E2056_String_literals_may_have_at_most_255_elements_(Delphi) https://stackoverflow.com/questions/8767899/how-can-delphi-string-literals-be-more-than-255#:~:text=In current versions of Delphi,is longer than 255 characters. hug Share this post Link to post
Attila Kovacs 629 Posted February 23, 2021 can we ban this clown @Lars Fosdal? Share this post Link to post
Lars Fosdal 1792 Posted February 23, 2021 2 hours ago, emailx45 said: maybe help you using "AnsiString" definition Make sure you understand the core issue before posting a googled suggestion. Good luck filling an AnsiString with a string literal longer than 255 chars. Oh wait, you can't. If I don't want to split up and combine multiple literals, loading from a resource string is an option. It just irks me that I can't initialize a string variable that can literally hold billions of characters with a single constant longer than 255 chars. 1 1 Share this post Link to post
David Heffernan 2345 Posted February 23, 2021 In reality you want to split them over multiple lines once they are that long so it's rare that it affects you. Share this post Link to post
Guest Posted February 23, 2021 4 hours ago, Attila Kovacs said: can we ban this clown worse than a clown, is a jester hurt by knowing that his mother is a cow. Share this post Link to post
Guest Posted February 23, 2021 (edited) 2 hours ago, Lars Fosdal said: Make sure you understand the core issue before posting a googled suggestion. Good luck filling an AnsiString with a string literal longer than 255 chars. Oh wait, you can't. hey Lars, see that one link is Embarcadero, not simple Googled! the limit is on Compiler, not on "string" only! same way that we have a size line limited on pure editor text or similar... the problem is a size of line, not necessary how many chars in the string! in time http://docs.embarcadero.com/products/rad_studio/radstudio2007/RS2007_helpupdates/HUpdate4/EN/html/delphivclwin32/System__AnsiString.html for remember the "begin" go back a little more. Quote Delphi utilizes several string types. The most important is the long string type, more commonly known as System::AnsiString. Support for this type includes the following features: strings as large as available memory; efficient use of memory through shared references; routines and operators that evaluate strings based on the current locale. Despite its name, System::AnsiString is not restricted to the ANSI character set, and can utilize any character set supported by the current locale definition, including multi-byte character sets. what was changed on Sydney edition? http://docwiki.embarcadero.com/Libraries/Sydney/en/System.AnsiString Quote Represents a dynamically allocated string whose maximum length is limited only by available memory. hug Edited February 23, 2021 by Guest Share this post Link to post
Lars Fosdal 1792 Posted February 24, 2021 So, @emailx45 - show me a code example of how you fill an ansistring using a single string literal longer than 255 chars in the source code. Not from a loop, concatenation, string resource, file, form resource, or copied from the clipboard at runtime. Share this post Link to post
Lars Fosdal 1792 Posted February 24, 2021 7 hours ago, David Heffernan said: In reality you want to split them over multiple lines once they are that long so it's rare that it affects you. True. Normally you would for readability, but splitting involves a manual operation that carries a risk of mangling the content. Yes, it is a compiler limit, but when you can split and add up a huge string "manually", it is annoying that the compiler can't hide this for you. /rant ended 1 Share this post Link to post
Guest Posted February 24, 2021 (edited) 2 hours ago, Lars Fosdal said: So, @emailx45 - show me a code example As you know, if i have it on hands, certally it would be here, not for only you but for all members! Now, you can hack the "Compiler" (if you can of course) and break this limitation! I think that the Embarcadero engineers dont see this as some sensible and doable for the life of a professional programmer! Bearing in mind that this limit is not limited to the Delphi compiler, just search using Google to see that it is a standard, quite possibly, due to the inheritance of ancient times, and, because of its unnecessary use. Since there are other ways to achieve this task. Really appears, for me, some insane want have a "literal string" in (just) one line with 750chars... but you have your necessity e disires! My advice: Use the MSWord, it is good for write books and cake recipe! and, if you have some others "inspirations beyond this life, you can also write some poetic or philosophical texts about the limitations of a programming language in the life of an ecstatic dreamer!" hug Edited February 24, 2021 by Guest Share this post Link to post
Lars Fosdal 1792 Posted February 24, 2021 @emailx45 It is great that you are enthusiastic and helpful - but - the wrong kind of help is not really helpful, is it? I guess you missed the "/rant" in my original post, as well as the comment about "logical, but annoying", and the explicit reference to string literals. I also clearly stated WHY I wanted a longer string literal; and @Angus Robertson provided another example of when this limit is a challenge. Yet you post a completely irrelevant suggestion that AnsiString is the answer to the problem. My advice: - Study posts until you are sure you understand the context - Avoid applying your own opinion as one of the Embarcadero engineers - Avoid what-about-ism - Avoid characterizing the desires of others as insane - Avoid posting bullshit comments not relevant to the discussion Fun fact: The line length limit in the Delphi IDE is 4096 chars. 8 Share this post Link to post
Bill Meyer 337 Posted February 24, 2021 4 hours ago, Lars Fosdal said: Fun fact: The line length limit in the Delphi IDE is 4096 chars. And despite the unwieldly nature of string literals you would have to scroll horizontally to read, that feature of the IDE begs the question of why the limit on the literals is 255. Share this post Link to post
Guest Posted February 24, 2021 (edited) 6 hours ago, Lars Fosdal said: Fun fact: The line length limit in the Delphi IDE is 4096 chars if it is, then, use it and still have same warning from Compiler. who knows one day you win this battle! my opinion is mine, i anybody dont have accept it or not. if it is very descrepant, simply appoint where, and ii can review it. Im not unmutable. now, be called of "clown" or "your text is a shiit" as did @Attila Kovacs should be so reproved, an personal attack for free. And you can see he have already did for 3times, and my last answer (not counting above) was: follow your way (to he), dont worry about my posts) but sometimes the primitive side emerge and the control is gone. Sorry about this. for the rest, I can express myself, independently if somebody like or not. if you desire, I'll not more participate on threads where you have some post. at end, you are the BOSS, and can wake up with a big "headache" and discont in my person. Then, same having another forums, I want stay in peace with all possible. if not possible, ok too. the internet is bigger, and, i can live in another community, as i did in old Idera Forum and others not more existent. sorry about my little knowledge and ignorance in the face of so many geniuses lost in their own doubts that can be clarified with a simple consultation in the language manual. And, So with any user of the language I can give an opinion on Embarcadero and its engineers, who, as is known by all, are having problems solving problems that made in these, and the last edition, practically impractical for use in some areas. hug Edited February 24, 2021 by Guest Share this post Link to post