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-Thread: 103376,c9019477667b9c0f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.73.229 with SMTP id o5mr6448592pbv.7.1323996951373; Thu, 15 Dec 2011 16:55:51 -0800 (PST) MIME-Version: 1.0 Path: lh20ni27207pbb.0!nntp.google.com!news2.google.com!goblin1!goblin.stu.neva.ru!news.tornevall.net!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Writing Data to a file Date: Thu, 15 Dec 2011 18:55:47 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <344d32d6-a667-407c-bb8e-e0c504e91688@u32g2000yqe.googlegroups.com> <87zketwure.fsf@ludovic-brenta.org> <530c4f5e-3c00-4ad5-92de-a4faefad468d@p16g2000yqd.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1323996950 26816 69.95.181.76 (16 Dec 2011 00:55:50 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 16 Dec 2011 00:55:50 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2011-12-15T18:55:47-06:00 List-Id: "awdorrin" wrote in message news:530c4f5e-3c00-4ad5-92de-a4faefad468d@p16g2000yqd.googlegroups.com... ... >So since all I have is a System.Address and offsets, I believe I have >to cast/convert this a Stream_Element_Array. Yes, probably. >If I could only access POSIX.IO's write 'function', rather than the >procedures, I wouldn't have to go through these hoops. >Of course, that write function is the equivalent of what I'm trying to >replace... You're not making any sense. The only difference between the POSIX.IO procedures and the imported function is that POSIX.IO gets rid of the (unused) result. The parameters and the meaning are the same (I think - I haven't used POSIX interfaces ever). >I'm not sure I see how the Stream_IO package could be used directly >for this. Once you've converted your address/length into a Stream_Element_Array, just call Write on the appropriate slice: Stream_IO.Write (File_Object, Buf (1 .. Buf_Last)); or even (given that your sample code already has set the correct length: Stream_IO.Write (File_Object, Buf); The "problem" here is getting a Stream_IO file object rather than a handle (which means you'll need to change the Open/Create calls, wherever they are), but that should be pretty simple. Randy. P.S. In looking at your original code, I realized that you never gave Buf_Last a value, so that's probably why your Write call is failing. (You're writing some random number of bytes, rather than the correct calculated number). P.P.S. In Janus/Ada, at least, the address clause would not work because you would relocate the array descriptor rather than the data. GNAT probably is different on this point, but I would not be certain if the clause works. P.P.P.S. The use of explicit Address should be avoided in new code, specifically because it is hard to do anything sensible with it. Use general access types (if the designated value is of a specific type) it at all possible. (And if not, I recommend use of A2A (Address_to_Access_Conversions - see 13.7.2).