comp.lang.ada
 help / color / mirror / Atom feed
* Pointer to Array
@ 2007-10-16 13:40 shaunpatterson
  2007-10-16 14:09 ` Niklas Holsti
  2007-10-16 14:16 ` Robert A Duff
  0 siblings, 2 replies; 3+ messages in thread
From: shaunpatterson @ 2007-10-16 13:40 UTC (permalink / 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




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

end of thread, other threads:[~2007-10-16 14:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-16 13:40 Pointer to Array shaunpatterson
2007-10-16 14:09 ` Niklas Holsti
2007-10-16 14:16 ` Robert A Duff

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