Can I use 'POS to find a character in a array ?

  • Thread starter HansWernerMarschke
  • Start date
H

HansWernerMarschke

If I have a array of character.

type wheel_string is array (char_index'left to char_index'right) of
character;

Can I use 'POS to find a character in the array ?

index := the_enigma.rotor(i).wheel'pos(ch);

Or do I have to compare every character with the one that I am looking
for ?

Thank you
 
K

KJ

If I have a array of character.

type wheel_string is array (char_index'left to char_index'right) of
character;

Can I use 'POS to find a character in the array ?

'pos returns the position within the array...I think that's what you
mean to say or ask.
index := the_enigma.rotor(i).wheel'pos(ch);

Assuming that 'index' is an integer than 'index' will be a number that
tells you the index within 'wheel_string' where the character 'ch' is
at.
Or do I have to compare every character with the one that I am looking
for ?

You shouldn't have to.

KJ
 
H

HansWernerMarschke

Can I assume that the record element
the_enigma.rotor(i).wheel
is of type wheel_string? If so, then the answer is very
clearly "no"; you're trying to search through this array,
locating the index at which character ch is found in it,
I assume. That's not even close to what 'pos is supposed
to do. Your example is surely illegal, isn't it? The
predefined attribute 'POS applies only to a discrete TYPE,
not to a data object.

Well, I got an error using this construct.
By discrete type you mean something like integer ?

May the FPGA be with you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top