Using ANSI Strings to avoid exceeding string limit at compile lazarus / 62-General ---------------------------------------------------------------------- tygraphics · 2020-09-29 20:36 When I try to compile my pascal code that has a string longer than 255 char I get the following error: VeryLongNames_G.p(24,250) Fatal: String exceeds line Is there a setting or flag that allows the compiler to accommodate strings that are greater than 255 char? Thanks! ---------------------------------------------------------------------- Handoko · 2020-09-29 20:37 Use {$H+}: https://www.freepascal.org/docs-html/prog/progsu25.html ---------------------------------------------------------------------- tygraphics · 2020-09-29 20:49 I placed the {$H+} on the main program but got the same error. Does it have to be added to any units that have long strings? After adding {$H+} to the unit with the long strings and it compiled! Thanks for the help! ---------------------------------------------------------------------- jwdietrich · 2020-09-29 20:52 Quote from: tygraphics on September 29, 2020, 10:49:02 pmI placed the {$H+} on the main program but got the same error. Does it have to be added to any units that have long strings? Yes, in the beginning before declaring or using any strings (but after mode directives). ---------------------------------------------------------------------- tygraphics · 2020-09-29 21:01 I'm generating the unit files as I parse through a collection of hundreds of components. Is there any harm in adding the {$H+} as a standard part of all my unit files? ---------------------------------------------------------------------- jwdietrich · 2020-09-29 21:07 Quote from: tygraphics on September 29, 2020, 11:01:00 pmI'm generating the unit files as I parse through a collection of hundreds of components. Is there any harm in adding the {$H+} as a standard part of all my unit files? Probably not, but if your code contains mode directives {$H+} may be deactivated again (with the exception of {$MODE DELPHI}, which implies {$H+}). ---------------------------------------------------------------------- Kays · 2020-09-29 22:43 Quote from: tygraphics on September 29, 2020, 11:01:00 pm[…] Is there any harm in adding the {$H+} as a standard part of all my unit files? You can write your own fpc.cfg and place -Sh (the command line option to enable ANSI strings by default) in it. ---------------------------------------------------------------------- lucamar · 2020-09-30 10:51 Quote from: tygraphics on September 29, 2020, 10:36:01 pmWhen I try to compile my pascal code that has a string longer than 255 char I get the following error: VeryLongNames_G.p(24,250) Fatal: String exceeds line For completeness sake, note also that the error doesn't normally mean that the string is too long but that it is not terminated in the same line, usually meaning that you have code like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i somestring := 'This string isn't well formed';instead of: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i somestring := 'This string isn''t well formed';(note the doubled single quotes in "isn''t") or that you forgot  to close the string (i.e. the last single quote is missing). HTH ---------------------------------------------------------------------- tygraphics · 2020-09-30 12:29 Yes, the string was malformed and that caused the error. It was malformed because of a hack I wrote many years ago that breaks long writeln statements into as many write statements as necessary to keep them under 250 char. Unfortunately in this case the chop point was in a bad location. Yesterday I fixed my code and it handled the 367 char string without error due to adding the {$H+} to the top of my generated units that could likely have a long string. Thank you to everyone who answered!