Weird concatenation

F

Franck Y

Guest
Hello,

I have some constant name like this

ok1
ok2
ok3
ok4 etc....

I am doing a loop
but i don't know how i can acces to those value

for i in 0 to 1loop

if (d_col_1(i)='1') then
go("ok"+i,red);

END IF;

But it wont't work do you have any clue ?

Thanks
 
Franck Y wrote:

Hello,

I have some constant name like this

ok1
ok2
ok3
ok4 etc....

I am doing a loop
but i don't know how i can acces to those value

for i in 0 to 1loop

if (d_col_1(i)='1') then
go("ok"+i,red);

END IF;

But it wont't work do you have any clue ?
If you want to access those constants in a loop, indexed by the loop
counter, you'll have to store those constants in an array.

For example:

TYPE ok_tbl_type IS ARRAY(natural RANGE <>) OF natural;
CONSTANT ok: ok_tbl_type :=
(
1 => 123,
2 => 456,
3 => 777,
4 => 999
);

In this example an array of naturals is chosen, but you can choose any type.

Then you can use ok(1), ok(2) etc, or use a loop:

FOR i IN ok'RANGE LOOP -- same as: FOR i IN 1 TO 4 LOOP
IF d_col_1(i) = '1' THEN
go(ok(i), red);
END IF;
END LOOP;

--
Paul Uiterlinden
www.aimvalley.nl
e-mail addres: remove the not.
 

Welcome to EDABoard.com

Sponsor

Back
Top