* A quickie problem with an array and a right hand bracket
@ 2001-06-11 17:08 chris.danx
2001-06-11 17:24 ` Ted Dennison
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: chris.danx @ 2001-06-11 17:08 UTC (permalink / raw)
Hello everyone,
I'm trying to provide an array for quickie conversion between numbers and
character equivalents like this
type array_16 is array (natural range 0..15) of character;
basic_16 : constant array_16 := ('0'..'9'|'a'..'f');
The compiler corrected me on the use of a comma where the dda ("d divides a",
from math sorry, it's a bar or more symbol) but this doesn't help with
"unexpected parenthesis error" when it's compiled. What's the problem? It
looks correct to me but clearly i am missing something (very subtle) point.
In case i get the use text_io and tear off the start and end parts for
displaying in other bases argument. I do not want to use text_io in this manner
since i want to remove (as much as possible) dependance on the standard packages
(for now).
Thanks,
Chris Campbell
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A quickie problem with an array and a right hand bracket
2001-06-11 17:08 A quickie problem with an array and a right hand bracket chris.danx
@ 2001-06-11 17:24 ` Ted Dennison
2001-06-11 22:45 ` Jeffrey Carter
2001-06-12 10:01 ` chris.danx
2 siblings, 0 replies; 4+ messages in thread
From: Ted Dennison @ 2001-06-11 17:24 UTC (permalink / raw)
In article <eV6V6.8331$6d5.1657665@news2-win.server.ntlworld.com>, chris.danx
says...
>I'm trying to provide an array for quickie conversion between numbers and
>character equivalents like this
>
> type array_16 is array (natural range 0..15) of character;
>
> basic_16 : constant array_16 := ('0'..'9'|'a'..'f');
I don't think you can use the '|' character that way. I'm not sure what your
right hand side would even mean if it were valid.
Probably the easiest way to do this would be:
basic_16 : constant array_16 := "0123456789abcdef";
Of course it would be even easier to just use "String" (or a subtype thereof)
instead of making your own character array type. But you may have your reasons
for that.
---
T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html
home email - mailto:dennison@telepath.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A quickie problem with an array and a right hand bracket
2001-06-11 17:08 A quickie problem with an array and a right hand bracket chris.danx
2001-06-11 17:24 ` Ted Dennison
@ 2001-06-11 22:45 ` Jeffrey Carter
2001-06-12 10:01 ` chris.danx
2 siblings, 0 replies; 4+ messages in thread
From: Jeffrey Carter @ 2001-06-11 22:45 UTC (permalink / raw)
"chris.danx" wrote:
>
> Hello everyone,
>
> I'm trying to provide an array for quickie conversion between numbers and
> character equivalents like this
>
> type array_16 is array (natural range 0..15) of character;
>
> basic_16 : constant array_16 := ('0'..'9'|'a'..'f');
>
> The compiler corrected me on the use of a comma where the dda ("d divides a",
> from math sorry, it's a bar or more symbol) but this doesn't help with
> "unexpected parenthesis error" when it's compiled. What's the problem? It
> looks correct to me but clearly i am missing something (very subtle) point.
Your compiler is expecting something like
('0' .. '9' | 'a' .. 'f' => Some_Value)
so hitting that right parenthesis is throwing it off. Later it would
complain that the index type in the aggregate (characters) does not
match the index type of Array_16 (Natural range 0 .. 15), but it's not
getting to that point.
Since Array_16 is a string type, you could simply use a string literal:
Basic_16 : constant Array_16 := "0123456789abcdef";
You can also use a normal aggregate:
Basic_16 : constant Array_16 :=
(0 => '0', 1 => '1', 2 => '2', 15 => 'f', 14 => 'e', 13 => 'd',
3 => '3', 4 => '4', 5 => '5', 12 => 'c', 11 => 'b', 10 => 'a',
6 => '6', 7 => '7', 8 => '8', 9 => '9');
--
Jeffrey Carter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A quickie problem with an array and a right hand bracket
2001-06-11 17:08 A quickie problem with an array and a right hand bracket chris.danx
2001-06-11 17:24 ` Ted Dennison
2001-06-11 22:45 ` Jeffrey Carter
@ 2001-06-12 10:01 ` chris.danx
2 siblings, 0 replies; 4+ messages in thread
From: chris.danx @ 2001-06-12 10:01 UTC (permalink / raw)
Thanks all,
Chris Campbell
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-06-12 10:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-11 17:08 A quickie problem with an array and a right hand bracket chris.danx
2001-06-11 17:24 ` Ted Dennison
2001-06-11 22:45 ` Jeffrey Carter
2001-06-12 10:01 ` chris.danx
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox