Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"jackpot: you may have an unnecessary change record" -- message from "diff"


devel / comp.lang.ada / Usage of Stream Set_Index() function

SubjectAuthor
* Usage of Stream Set_Index() functionDrPi
`* Re: Usage of Stream Set_Index() functionNiklas Holsti
 `* Re: Usage of Stream Set_Index() functionDrPi
  `- Re: Usage of Stream Set_Index() functionАлексей Деркач

1
Usage of Stream Set_Index() function

<61e1c144$0$6478$426a74cc@news.free.fr>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=6536&group=comp.lang.ada#6536

 copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!rocksolid2!news.neodome.net!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!abe005.abavia.com!abe001.abavia.com!proxad.net!feeder1-1.proxad.net!cleanfeed1-b.proxad.net!nnrp4-2.free.fr!not-for-mail
Date: Fri, 14 Jan 2022 19:30:25 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Newsgroups: comp.lang.ada
Content-Language: en-US
From: 314...@drpi.fr (DrPi)
Subject: Usage of Stream Set_Index() function
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 19
Message-ID: <61e1c144$0$6478$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 14 Jan 2022 19:30:28 CET
NNTP-Posting-Host: 82.65.30.55
X-Trace: 1642185028 news-1.free.fr 6478 82.65.30.55:58440
X-Complaints-To: abuse@proxad.net
X-Received-Bytes: 1514
 by: DrPi - Fri, 14 Jan 2022 18:30 UTC

Hi,

I'm writing an application where I read a file with a complex structure.
For this, I use Ada.Streams.Stream_IO package.
To read the file, I need to position the file pointer to the correct
location. I do this using Set_Index().

In ARM A.12.1, it is stated :
For Read and Write with a Positive_Count parameter, the value of the
current index is set to the value of the Positive_Count parameter plus
the number of stream elements read or written.

I don't understand the "plus the number of stream elements read or written".

Does this mean one can't go back to beginning of file once data have
been read ?

Nicolas

Re: Usage of Stream Set_Index() function

<j4e555F1iffU1@mid.individual.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=6537&group=comp.lang.ada#6537

 copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Usage of Stream Set_Index() function
Date: Fri, 14 Jan 2022 22:35:49 +0200
Organization: Tidorum Ltd
Lines: 50
Message-ID: <j4e555F1iffU1@mid.individual.net>
References: <61e1c144$0$6478$426a74cc@news.free.fr>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net Rl8Cg9dU/bJpAmrHwKdGNA/lR+t9Gv5uNsyDdrLN2U5Niv5mBW
Cancel-Lock: sha1:jdoJKPENnHlj8H4T/SRymXlUG9Y=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.14.0
In-Reply-To: <61e1c144$0$6478$426a74cc@news.free.fr>
Content-Language: en-US
 by: Niklas Holsti - Fri, 14 Jan 2022 20:35 UTC

On 2022-01-14 20:30, DrPi wrote:
>
> Hi,
>
> I'm writing an application where I read a file with a complex structure.
> For this, I use Ada.Streams.Stream_IO package.
> To read the file, I need to position the file pointer to the correct
> location. I do this using Set_Index().
>
> In ARM A.12.1, it is stated :
> For Read and Write with a Positive_Count parameter, the value of the
> current index is set to the value of the Positive_Count parameter plus
> the number of stream elements read or written.
>
> I don't understand the "plus the number of stream elements read or
> written".

For Write, the ARM also says: "The Write procedure with a Positive_Count
parameter starts writing at the specified index". And then, after the
data have been written, naturally the current index of the stream has
been increased, to point at the position after the written data. That is
the meaning of the "plus" phrase.

And Read analogously. The "plus" phrase explains what the value of the
current index is _after_ the Read or Write. But both the Read and the
Write _start_ reading/writing at the index given in the From/To parameters.

> Does this mean one can't go back to beginning of file once data have
> been read ?

No, Set_Index can do that, whether the last action was writing or
reading. And the Write/Read with an index parameter can also do that.

But if you have set the current index to the desired position with
Set_Index, you don't need to use the Read/Write that have a
Positive_Count (index) parameter.

This code:

Set_Index (F, I);
Write (F, Item);

is equivalent to:

Write (F, Item, I);

and ditto Read.

Re: Usage of Stream Set_Index() function

<61e2a3a0$0$8882$426a34cc@news.free.fr>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=6539&group=comp.lang.ada#6539

 copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.nntp4.net!weretis.net!feeder8.news.weretis.net!npeer.as286.net!npeer-ng0.as286.net!proxad.net!feeder1-1.proxad.net!cleanfeed1-a.proxad.net!nnrp1-1.free.fr!not-for-mail
Date: Sat, 15 Jan 2022 11:36:15 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Content-Language: en-US
Newsgroups: comp.lang.ada
References: <61e1c144$0$6478$426a74cc@news.free.fr>
<j4e555F1iffU1@mid.individual.net>
From: 314...@drpi.fr (DrPi)
Subject: Re: Usage of Stream Set_Index() function
In-Reply-To: <j4e555F1iffU1@mid.individual.net>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 69
Message-ID: <61e2a3a0$0$8882$426a34cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 15 Jan 2022 11:36:16 CET
NNTP-Posting-Host: 82.65.30.55
X-Trace: 1642242976 news-4.free.fr 8882 82.65.30.55:58715
X-Complaints-To: abuse@proxad.net
 by: DrPi - Sat, 15 Jan 2022 10:36 UTC

Le 14/01/2022 à 21:35, Niklas Holsti a écrit :
> On 2022-01-14 20:30, DrPi wrote:
>>
>> Hi,
>>
>> I'm writing an application where I read a file with a complex structure.
>> For this, I use Ada.Streams.Stream_IO package.
>> To read the file, I need to position the file pointer to the correct
>> location. I do this using Set_Index().
>>
>> In ARM A.12.1, it is stated :
>> For Read and Write with a Positive_Count parameter, the value of the
>> current index is set to the value of the Positive_Count parameter plus
>> the number of stream elements read or written.
>>
>> I don't understand the "plus the number of stream elements read or
>> written".
>
>
> For Write, the ARM also says: "The Write procedure with a Positive_Count
> parameter starts writing at the specified index". And then, after the
> data have been written, naturally the current index of the stream has
> been increased, to point at the position after the written data. That is
> the meaning of the "plus" phrase.
>
> And Read analogously. The "plus" phrase explains what the value of the
> current index is _after_ the Read or Write. But both the Read and the
> Write _start_ reading/writing at the index given in the From/To parameters.
>
>
>> Does this mean one can't go back to beginning of file once data have
>> been read ?
>
>
> No, Set_Index can do that, whether the last action was writing or
> reading. And the Write/Read with an index parameter can also do that.
>
> But if you have set the current index to the desired position with
> Set_Index, you don't need to use the Read/Write that have a
> Positive_Count (index) parameter.
>
> This code:
>
>    Set_Index (F, I);
>    Write (F, Item);
>
> is equivalent to:
>
>    Write (F, Item, I);
>
> and ditto Read.

Ok, so Set_Index() works as expected. Nothing special.

Reading the LRM made me understand things incorrectly because of the way
it is written.

It is written :
32 The Set_Index procedure sets the current index to the specified value.

Then, it is written :
32.1/1 ...
32.2/1 ...
....

Reading this, I thought 32.1/1, 32.2/1 etc lines apply to 32
(Set_Index() function).
So, I was completely lost to understand the meaning of these lines.

Re: Usage of Stream Set_Index() function

<68b852d0-4121-4930-9f40-1d648b9fccfbn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=6561&group=comp.lang.ada#6561

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:6214:3011:: with SMTP id ke17mr9995493qvb.63.1643028027653;
Mon, 24 Jan 2022 04:40:27 -0800 (PST)
X-Received: by 2002:a25:8d10:: with SMTP id n16mr22514268ybl.696.1643028027419;
Mon, 24 Jan 2022 04:40:27 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 24 Jan 2022 04:40:27 -0800 (PST)
In-Reply-To: <61e2a3a0$0$8882$426a34cc@news.free.fr>
Injection-Info: google-groups.googlegroups.com; posting-host=185.245.84.50; posting-account=1ohbkQoAAAA16C42XACKoxlDnXjwS_ze
NNTP-Posting-Host: 185.245.84.50
References: <61e1c144$0$6478$426a74cc@news.free.fr> <j4e555F1iffU1@mid.individual.net>
<61e2a3a0$0$8882$426a34cc@news.free.fr>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <68b852d0-4121-4930-9f40-1d648b9fccfbn@googlegroups.com>
Subject: Re: Usage of Stream Set_Index() function
From: alexejde...@ukr.net (Алексей Деркач)
Injection-Date: Mon, 24 Jan 2022 12:40:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 6
 by: Алексей Де - Mon, 24 Jan 2022 12:40 UTC

I can suggest, by the way, to many students who are also looking to order a good and high-quality essay for themselves. It is necessary to get acquainted in advance with the companies that can help with such services. I already know for sure that it will be better to turn here https://www.topwritersreview.com/reviews/get-essay/ to get acquainted with one of them in detail. It helped me to figure it out, I hope it will help you too.

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor