C:\dev32\fpc\test>..\bin\i386-win32\fpc.exe test.pp
Free Pascal Compiler version 3.1.1 [2018/04/24] for i386
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test.pp
Linking test.exe
21 lines compiled, 0.0 sec, 28608 bytes code, 1348 bytes data
C:\dev32\fpc\test>test
Neither HAHA!
NONE OF THOSE HAHA
C:\dev32\fpc\test>
and this with Laz 1.8.2 FPC 3.0.4:C:\dev32\fpc\test>c:\laz.1.8\fpc\3.0.4\bin\x86_64-win64\fpc test.pp
Free Pascal Compiler version 3.0.4 [2018/02/25] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling test.pp
Linking test.exe
21 lines compiled, 0.1 sec, 33136 bytes code, 1364 bytes data
C:\dev32\fpc\test>test
A or a..z
Ch IInd Statement
C:\dev32\fpc\test>
'a'..'z' is translated as (>= 'a') and (<= 'z').
It's also logical that using ranges with strings is dangerous and should not be done.
Bart, 'A', 'a'..'z' is AnsiChar syntax - not string syntax - and always allowed because AnsiChars are enumerable.It's also logical that using ranges with strings is dangerous and should not be done.
Why then does FPC syntax allow it?
Bart, 'A', 'a'..'z' is AnsiChar syntax - not string syntax - and always allowed because AnsiChars are enumerable.
Why "and lenght(s)=1"?Because, IMHO, it makes this case statement produce correct1 results when the case variable is string, if this syntax to be supported. The other alternative, for the programmer, would be to expand 'a'..'z' manually as 'a','b','c' etc. or to have two case statements for s and s[1].
I tested it's if then else equivalent and what you said is right, it evaluates to true for all strings that start with a..y (regardless of what the rest of the characters in that string are.. even string amBER_%%%@ worked).
It works for string 'z' as well. But why don't strings like zoom, z' or 'z ' (z+space) or any string that starts with character 'z' and length > 1 work? %)