B and C are strings. I tryed to cast to cast them to strings, anyway, but still I get the same error? Is it me doing sth. wrong?
Title: Re: „Error: Constant and CASE types do not match‟ with string
Post by: RayoGlauco on July 09, 2018, 03:49:09 pm
In the second example, you use variables as selectors, instead of constants (B is a variable; 'B' is a constant). You cannot use variables as selectors.
See http://wiki.freepascal.org/Case (http://wiki.freepascal.org/Case)
Title: Re: „Error: Constant and CASE types do not match‟ with string
Post by: Thaddy on July 09, 2018, 03:50:04 pm
Needs a literal value, indeed.
Title: Re: „Error: Constant and CASE types do not match‟ with string
Post by: Gammatester on July 09, 2018, 03:50:20 pm
You should read the second part of the error message 'Error: String expression expected'. The case labels must be constants (i.e. literals or true constants). Your construct would throw equivalent message even for integer variables. The following code does work: