Using SetLength in Free Pascal

I don’t see Pascal in the categories, but I am going to try anyway. I have a simple program that when I compile I keep getting the error “string exceeds line”, but I specified the length of the string. Here is my code:

program c;
Var s: String;
Begin

SetLength(s, 500000);
s := StringOfChar(’ …

Out of curiousity, what sort of thing are you putting in the …'s?

  1. Is it 500,000 characters long?
  2. Does it contain line breaks?
  3. What’re you coding this in specifically? (Is this an old Pascal engine that is using a string limited to 255 characters?)
1 Like

https://www.freepascal.org/docs-html/rtl/system/length.html

As said in the docs :slight_smile:

Funny to see how people nowadays assume holding MB of data in a variable is totally normal. When I learned Pascal the whole computer had 8kb RAM…

3 Likes

Not according to the documentation that Thallius listed to you…

So it depends on what kind of string you created.

From looking it up, StringOfChar() expects the first parameter to be a single character, and the second parameter to be a count of characters, and returns a string made of that one character repeated ‘count’ times. Just wondering if that’s actually how you’re calling it?

It’s been about 45 years since I wrote Pascal - fun to see someone’s using it still!

Thanks! That explains a lot of what I am going through.