From: AdaMagica <christ-usch.grein@t-online.de>
Subject: Re: Re-write a file in Ada
Date: Mon, 18 Jan 2016 01:50:38 -0800 (PST)
Date: 2016-01-18T01:50:38-08:00 [thread overview]
Message-ID: <c9a66bc8-c6c6-4fa9-b105-14fca2ffff25@googlegroups.com> (raw)
In-Reply-To: <eab1739b-264f-42c1-a03d-b244995dacbe@googlegroups.com>
Am Montag, 18. Januar 2016 01:22:22 UTC+1 schrieb comicf...@gmail.com:
> First , I want to copy every line in a file , in a array of unbounded_Strings , to work on them later .
>
> The problem is that i don't want to give a specific
> range at initializing .
>
> In fact , it size must be known according to the number of lines in the file .
How about giving an upper bound of 1000 or 10_000 lines? This should be enough for most cases.
> WITH Ada.Text_IO ; USE Ada.Text_IO ;
> WITH Ada.Text_IO.Unbounded_IO ; USE Ada.Text_IO.Unbounded_IO ;
> WITH Ada.Strings.Unbounded ; USE Ada.Strings.Unbounded ;
>
> Procedure main is
>
> this_file : File_type ;
>
Last_case : Natural := 0 ; -- last filled line
Type T_Tableau is array (1 .. 10_000) of unbounded_string ;
-- size with upper limit to the number of lines in the file.
case_of_array : T_Tableau ; -- now a definite type
>
> Begin
>
> Open
> (File => this_file ,
> Mode => In_file ,
> Name => "main.adb");
>
> loop exit when End_Of_File ( this_file ) ;
>
> case_of_array( Last_case ) := Get_Line( this_file );
>
> Last_case := Last_case + 1 ;
> end loop ;
> End main ;
next prev parent reply other threads:[~2016-01-18 9:50 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-06 15:55 Re-write a file in Ada comicfanzine
2016-01-07 13:02 ` comicfanzine
2016-01-08 20:35 ` comicfanzine
2016-01-09 9:50 ` Brian Drummond
2016-01-08 21:22 ` Randy Brukardt
2016-01-08 22:08 ` Anh Vo
2016-01-10 16:54 ` comicfanzine
2016-01-10 18:59 ` Björn Lundin
2016-01-11 17:16 ` Brian Drummond
2016-01-18 15:05 ` gautier_niouzes
2016-01-19 12:24 ` Brian Drummond
2016-01-19 16:52 ` gautier_niouzes
2016-01-21 12:26 ` Brian Drummond
2016-01-10 22:57 ` comicfanzine
2016-01-11 1:59 ` Anh Vo
2016-01-11 10:09 ` Björn Lundin
2016-01-18 0:22 ` comicfanzine
2016-01-18 9:50 ` AdaMagica [this message]
2016-01-18 17:27 ` Björn Lundin
2016-01-18 11:52 ` Brian Drummond
2016-01-18 17:30 ` Björn Lundin
2016-01-18 17:25 ` comicfanzine
2016-01-18 17:49 ` J-P. Rosen
2016-01-18 18:37 ` Simon Wright
2016-01-19 12:33 ` Brian Drummond
2016-01-19 14:40 ` Simon Wright
2016-01-21 12:31 ` Brian Drummond
2016-01-19 12:04 ` comicfanzine
2016-01-19 14:29 ` Anh Vo
2016-01-19 14:35 ` Simon Wright
2016-01-19 16:54 ` Jeffrey R. Carter
2016-01-19 17:32 ` Anh Vo
2016-01-19 16:53 ` Stephen Davies
2016-01-20 1:12 ` comicfanzine
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox