My jaw hit the ground when I got this error message out of what I thought was pretty standard Pascal:
and then in the actual code area:
I get an error "Got Constant String expected Char
When I first encountered Pascal, back in the 70s, I learnt that the way to initialize a char variable to 'nothing' was to use the form I gave above, assigning it to an empty string constant.
The guidance (from Free Pascal and Lazarus {translated from the Russian}) is:
The values of character variables and constants must be enclosed in single
quotation marks, such as: 'a', 'b', '+', in source code.
So, faced with a grumpy compiler, I went back and defined a new variable:
at which point
worked just fine.
Sooooo..
if a String is really a Packed array of charcters and char is a single character, and we can index into a string and bring out a character, then why can't we just assign the '' value to the char variable?
I could construct an empty string (st := ''; ) but then it wouldn't have any characters, so I can't get at them via the indexing method. The same goes for adding any number of empty strings - they don't exist so I can't access them. I get that.
If
you have a character variable that you want to initialize, how do you do it?
Confused, cranky and curmudgeonly,
Tony