Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Passing Range Parameters to new instance of unbounded, boxed <> array in Ada

57 views
Skip to first unread message

Mace Ayres

unread,
Jul 13, 2021, 10:53:51 PM7/13/21
to
1) I declare - Type a_gear is array(index range <>) of Intgeger;

2) I want to create an instance of type a_gear
Gear : a_gear (var_strt..var_end);
————————————-
Both 1 and 2 must be declared after …. an ‘Is’ and before a ‘BEGIN’ of any code block

but I can’t code a sub program to get a user’s input for var_strt and var_end until after a BEGIN statement which too late to pass to the parameterized unbounded/Box array gear.

I am not getting the proper visibility and scope to capture user’s parameters before I declare an instance, gear, of the type a_gear, an unbounded array?

J-P. Rosen

unread,
Jul 14, 2021, 2:18:51 AM7/14/21
to
This is a classical case for a "declare" block:

procedure Your_Proc is
begin
... get Var_Strt and Var_End here ...

declare
Gear : a_gear (var_strt..var_end);
begin
... use your variable here ...
end;
end Your_Proc;

--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52
https://www.adalog.fr
0 new messages