[fpc-devel] Some new
J. Gareth Moreton
gareth at moreton-family.com
Tue Mar 5 09:26:37 CET 2019
Heh, okay, I stand corrected. Thanks Michael. Seems I need to read up
on all the functions in the standard units. Sorry for wasting everyone's
time.
I do wonder though if it's worth adding " in " to SysUtils, since it's a
very convenient and intuitive notation... not just for Chars but for all
basic types, actually.
Gareth aka. Kit
On Tue 05/03/19 09:05 , "Michael Van Canneyt" michael at freepascal.org sent:
On Tue, 5 Mar 2019, J. Gareth Moreton wrote:
> Ah, okay. In my case, it doesn't work if the set you specify is a
> constant or variable defined elsewhere.
>
> e.g.
>
> const Delimiters: array[0..5] of Char = [#9, #10, #12, #13, #26, #32];
>
> if C in Delimiters then...
> If you do that, you get a compiler error about 'in' not being overloaded
> or some such.
That's because you're defining an array, not a set.
To define it as a set do:
Const
Delimiters = [#9, #10, #12, #13, #26, #32];
Your c in delimiters will work because this is a set.
The FPC source tree is full of such constructs.
The sysutils unit has CharInSet() BTW, if you want to use an array.
Michael.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190305/a19d75c8/attachment.html>
More information about the fpc-devel
mailing list