comp.lang.ada
 help / color / mirror / Atom feed
* Passing Range Parameters to new instance of unbounded, boxed <> array in Ada
@ 2021-07-14  2:53 Mace Ayres
  2021-07-14  6:18 ` J-P. Rosen
  0 siblings, 1 reply; 2+ messages in thread
From: Mace Ayres @ 2021-07-14  2:53 UTC (permalink / raw)


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?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Passing Range Parameters to new instance of unbounded, boxed <> array in Ada
  2021-07-14  2:53 Passing Range Parameters to new instance of unbounded, boxed <> array in Ada Mace Ayres
@ 2021-07-14  6:18 ` J-P. Rosen
  0 siblings, 0 replies; 2+ messages in thread
From: J-P. Rosen @ 2021-07-14  6:18 UTC (permalink / raw)


Le 14/07/2021 à 04:53, Mace Ayres a écrit :
> 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?
> 
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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-14  6:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14  2:53 Passing Range Parameters to new instance of unbounded, boxed <> array in Ada Mace Ayres
2021-07-14  6:18 ` J-P. Rosen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox