From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2151e8951b93233f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-23 02:34:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!colt.net!peernews2.colt.net!news0.de.colt.net!blackbush.xlink.net!blackbush.de.kpnqwest.net!news.erfurt.thur.de!drcomp.erfurt.thur.de!not-for-mail From: Adrian Knoth Newsgroups: comp.lang.ada Subject: Re: Put_Line for chars_ptr Date: 23 Jun 2002 09:20:06 GMT Organization: Modern Electronics Message-ID: References: NNTP-Posting-Host: drcomp.erfurt.thur.de X-Server-Date: 23 Jun 2002 09:20:06 GMT User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:26621 Date: 2002-06-23T09:20:06+00:00 List-Id: tmoran@acm.org wrote: >> via Value(varname.sysname) & ... &... it cannot handle a null-pointer >> (raise Dereference-Error). > What else should Value(null pointer) do? But there is no null pointer. It only complains about it, the record is filled out. > How about using something like: > function S(Item : in chars_ptr) return String is > begin > if Item = Null_Ptr then return "?"; > else return Value(Item); > end S; This is exactly the code Interfaces.C.Strings uses: function Value (Item : in chars_ptr) return char_array is Result : char_array (0 .. Strlen (Item)); begin if Item = Null_Ptr then raise Dereference_Error; end if; -- Note that the following loop will also copy the terminating Nul for J in Result'Range loop Result (J) := Peek (Item + J); end loop; return Result; end Value; (it first generates char_array from chars_ptr and then converts this array via To_Ada to an ordinary string: function Value (Item : in chars_ptr) return String is begin return To_Ada (Value (Item)); end Value; I think this is what I want to do, but it fails. Sometimes with storage_error. -- mail: adi@thur.de http://adi.thur.de PGP: v2-key via keyserver Never underestimate the power of a small tactical nuclear weapon.