comp.lang.ada
 help / color / mirror / Atom feed
* Re: Printing the address
       [not found] <609a5eaf$0$20558$e4fe514c@news.kpn.nl>
@ 2021-05-11 12:35 ` Maxim Reznik
  2021-05-11 14:55   ` Niklas Holsti
  2021-05-11 12:41 ` Niklas Holsti
  1 sibling, 1 reply; 3+ messages in thread
From: Maxim Reznik @ 2021-05-11 12:35 UTC (permalink / raw)


Actually, you don't need the address image to find if it is null. You can print instead

Put_Line (Boolean'Image (Boxes (n) = null));

When you really need the address image you can use

function System.Address_Image (A : Address) return String;

and an instantiation of

System.Address_To_Access_Conversions

generic package to convert Box_Acces value to System.Address.

PS. BTW, I would use a debugger in such cases.

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

* Re: Printing the address
       [not found] <609a5eaf$0$20558$e4fe514c@news.kpn.nl>
  2021-05-11 12:35 ` Printing the address Maxim Reznik
@ 2021-05-11 12:41 ` Niklas Holsti
  1 sibling, 0 replies; 3+ messages in thread
From: Niklas Holsti @ 2021-05-11 12:41 UTC (permalink / raw)


On 2021-05-11 13:38, ldries46 wrote:
> I Get an contstraint error in the line:
> /if Boxes(n).Status = manual or Boxes(n).Status = auto then/


That is either becase "n" is not in Boxes'Range, or because Boxes(n) is 
null. From the rest of your message, it seems you believe that the 
latter is the cause.

(Btw, a briefer expression is

    if Boxes(n).Status in manual | auto then ...

assuming that Box_Status is a discrete type.)


> where/:
>     Boxes     : Ar_Box;
>     type Box is record
>        Status  : Box_Status;
>        Nrs_pos : Ar_Pos;
>        x_val   : integer;
>        y_val   : integer;
>        Fill    : integer;
>     end record;
> ///   type Box_Acces is access all Box;
> /   type Ar_Box is array (1 .. Max_Num) of Box_Acces;
> 
> /To debug the program I need to finf where the constraint is
> possible a 0x0 somewhere in Box


I assume you mean that some element of Boxes is a null access. That may 
or may not be represented as 16#0#.


> How can I priint this value I tried converting it to and integer but I 
> couldn'd get that working


You don't have to print the value. All that should matter to you is 
whether the value is null or not, so:

    Put (if Boxes(n) = null then "null" else "not null");

(If you really want to print the address, do

    System.Storage_Elements.Integer_Address'Image (
       System.Storage_Elements.To_Integer (Boxes(n).all'Address))

but be sure to check for a null value of Boxes(n) first.)

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

* Re: Printing the address
  2021-05-11 12:35 ` Printing the address Maxim Reznik
@ 2021-05-11 14:55   ` Niklas Holsti
  0 siblings, 0 replies; 3+ messages in thread
From: Niklas Holsti @ 2021-05-11 14:55 UTC (permalink / raw)


On 2021-05-11 15:35, Maxim Reznik wrote:

> When you really need the address image you can use
> 
> function System.Address_Image (A : Address) return String;


That seems not to be a standard function, at least I can't find it in 
Ada RM 2012 or RM (draft) 202X. Probably a GNAT-specific addition to 
package System.

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

end of thread, other threads:[~2021-05-11 14:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <609a5eaf$0$20558$e4fe514c@news.kpn.nl>
2021-05-11 12:35 ` Printing the address Maxim Reznik
2021-05-11 14:55   ` Niklas Holsti
2021-05-11 12:41 ` Niklas Holsti

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