comp.lang.ada
 help / color / mirror / Atom feed
* Access type problem.
@ 1998-08-20  0:00 Barry L. Dorough
  1998-08-20  0:00 ` David C. Hoos, Sr.
  0 siblings, 1 reply; 2+ messages in thread
From: Barry L. Dorough @ 1998-08-20  0:00 UTC (permalink / raw)


    I have some code where I have been carrying extra records around
because I don't know how to make the proper access type assignment.  Any
help would be greatly appreciated.

ex).  This is from memory I am not able to post the actual code.  Sorry
for any errors.

type Track_Data_Type is record
  Threat_Number : Integer;
  Threat_Id : Integer;
  X : Long_Float;
  Y : Long_Float;
  Z : Long_Float;
end record;

type Track_Data_Access is access Track_Data_Type;
type Track_Data_Array is array (Integer range <>) of Track_Data_Type;
type Track_Data_Array_Access is access Track_Data_Array;

type Map_Type is record
  Int_Obj : Track_Data_Array_Access := new Track_Data_Array(1..10);
  -- In reality this is allocated dynamically based on current air
picture
  Tgt_Obj : Track_Data_Array_Access:= new Track_Data_Array(1..10);
  -- In reality this is allocated dynamically based on current air
picture
end record;

type Current_Pair_Type is record
  Interceptor : Track_Data_Access;
  Target : Track_Data_Access;
end record;
-- In reality there is a Current_Pair_Type allocated for each pairing
saved in a linked list

procedure Assign_Current_Pair( Map : in Map_Type;
                                                  Int_Index : in
Integer;
                                                  Tgt_Index: in Integer;

                                                  Pair : in out
Current_Pair_Type) is
begin
-- This is the crux of my problem.  At present the Current_Pair_Type has

-- Track_Data_Type instead of Track_Data_Access and my code looks like
Pair.Interceptor := Map.Int_Obj(Int_Index);
Pair.Target := Map.Tgt_Obj(Tgt_Index);
-- I would have thought that this would work with the access types also,
but
-- I get type miss match errors.
end Assign Current_Pair;





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

* Re: Access type problem.
  1998-08-20  0:00 Access type problem Barry L. Dorough
@ 1998-08-20  0:00 ` David C. Hoos, Sr.
  0 siblings, 0 replies; 2+ messages in thread
From: David C. Hoos, Sr. @ 1998-08-20  0:00 UTC (permalink / raw)



Barry L. Dorough wrote in message <35DC295E.D6A41D97@hiwaay.net>...
>    I have some code where I have been carrying extra records around
>because I don't know how to make the proper access type assignment.  Any
>help would be greatly appreciated.
>
Here is your example, modified so it will compile.
The four changed lines are commented
-- begin source code --
package Dorough is

   type Track_Data_Type is record
      Threat_Number : Integer;
      Threat_Id : Integer;
      X : Long_Float;
      Y : Long_Float;
      Z : Long_Float;
   end record;

   type Track_Data_Access is access all Track_Data_Type; -- changed --
   type Track_Data_Array is array (Integer range <>) of aliased
Track_Data_Type; -- changed
   type Track_Data_Array_Access is access Track_Data_Array;

   type Map_Type is record
      Int_Obj : Track_Data_Array_Access := new Track_Data_Array(1..10);
      -- In reality this is allocated dynamically based on current air
picture
      Tgt_Obj : Track_Data_Array_Access:= new Track_Data_Array(1..10);
      -- In reality this is allocated dynamically based on current air
picture
   end record;

   type Current_Pair_Type is record
      Interceptor : Track_Data_Access;
      Target : Track_Data_Access;
   end record;
   -- In reality there is a Current_Pair_Type allocated for each pairing
saved in a linked list

   procedure Assign_Current_Pair( Map : in Map_Type;
      Int_Index : in
      Integer;
      Tgt_Index: in Integer;

      Pair : in out
      Current_Pair_Type);

end Dorough;

package body Dorough is

   procedure Assign_Current_Pair( Map : in Map_Type;
         Int_Index : in
         Integer;
         Tgt_Index: in Integer;

         Pair : in out
         Current_Pair_Type) is
   begin
      -- This is the crux of my problem. At present the Current_Pair_Type
has

      -- Track_Data_Type instead of Track_Data_Access and my code looks like
      Pair.Interceptor := Map.Int_Obj (Int_Index) 'access; -- changed
      Pair.Target := Map.Tgt_Obj (Tgt_Index) 'access; -- changed
      -- I would have thought that this would work with the access types
also, But
      -- I get type miss match errors.
   end Assign_Current_Pair;

end Dorough;
-- end source code --

David C. Hoos, Sr.







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

end of thread, other threads:[~1998-08-20  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-08-20  0:00 Access type problem Barry L. Dorough
1998-08-20  0:00 ` David C. Hoos, Sr.

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