comp.lang.ada
 help / color / mirror / Atom feed
From: shaunpatterson@gmail.com
Subject: Pointer to Array
Date: Tue, 16 Oct 2007 06:40:30 -0700
Date: 2007-10-16T06:40:30-07:00	[thread overview]
Message-ID: <1192542030.745091.64900@q5g2000prf.googlegroups.com> (raw)

I'm attempting to make a pointer to an array... or in a sense
"rename" an array.

I'm combining code from two very similar systems.  Lots of code.

I have thousands of lines of code that's exactly the same, using
(for just an example) an array of Integers.

There is a store file in each system that declares:

-- system 1
    type INT_ARRAY is new Integer (1..SYSTEM_1_SIZE);

    Int_Array_Var : INT_ARRAY;

-- system 2
    type INT_ARRAY is new Integer (1..SYSTEM_2_SIZE);
    Int_Array_Var : INT_ARRAY;

---------

so in other words, the variable names are the same, types are the same
only the size of the array is different..

then I have code in both systems that use that array like:

For I in Int_Array_Var'Range loop
       -- Do lots of stuff with Int_Array_Var
end loop

------
I want to keep that code untouched if possible.  I'm hoping there is a
way
in Ada to do something like

    type INT_ARRAY is array (Positive range <>) of Integer;
    Int_Array_Var_System1 : INT_ARRAY (1..System_1_Size);
    Int_Array_Var_System2 : INT_ARRAY (1..System_2_Size);


And I'd like to so something at run time that is like:

    if usingSystem1 then
        Int_array_Var = "pointer to Int_Array_Var_System1"
    elsif usingSystem2 then
        Int_array_Var = "pointer to Int_Array_Var_System2"

by changing the pointer I'm hoping to keep most of existing code the
same.

Is there any method in ada to do this?

-
Shaun




             reply	other threads:[~2007-10-16 13:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-16 13:40 shaunpatterson [this message]
2007-10-16 14:09 ` Pointer to Array Niklas Holsti
2007-10-16 14:16 ` Robert A Duff
replies disabled

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