Re: Accessing The Command Line

Liste des GroupesRevenir à cl ada 
Sujet : Re: Accessing The Command Line
De : spam.jrcarter.not (at) *nospam* spam.acm.org.not (Jeffrey R.Carter)
Groupes : comp.lang.ada
Date : 04. Jul 2024, 12:27:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v660u9$2nt74$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 2024-07-04 02:08, Lawrence D'Oliveiro wrote:
Remember that you can concatenate strings:

     tio.put("my name: ");
     tio.put(cli.Command_name);
     tio.Put_Line("");
Tio.Put_Line (Item => "my name: " & Cli.Command_Name);
Image functions thus allow similar simplifications. 'Image is one such function, if you can accept the initial space for non-negative values:

     tio.Put("nr args: ");
     int_io.Put(cli.Argument_Count, width => 1);
     tio.Put_Line("");
Tio.Put_Line (Item => "nr args:" & Cli.Argument_Count'Image);
For simple cases you can roll your own:
function Image (Value : in Integer) return String is
    Raw : constant String := Value'Image;
begin -- Image
    return Raw ( (if Value < 0 then 1 else 2) .. Raw'Last);
end Image;

         tio.put("[");
         int_io.put(i, width => 1);
         tio.put("]: ");
         tio.put(cli.argument(i));
         tio.put_line("");
Tio.Put_Line (Item => '[' & Image (I) & "]: " & Image (Cli.Argument (I) ) );
For more complex uses, you can use something like PragmARC.Images[.Image] (https://github.com/jrcarter/PragmARC).
You probably should review the definition of Ada.Text_IO (http://www.ada-auth.org/standards/aarm12_w_tc1/html/AA-A-10.html), especially for procedure New_Line.
--
Jeff Carter
"Write clearly--don't sacrifice clarity for 'efficiency.'"
Elements of Programming Style
186

Date Sujet#  Auteur
4 Jul 24 * Accessing The Command Line11Lawrence D'Oliveiro
4 Jul 24 +* Re: Accessing The Command Line4Paul Rubin
4 Jul 24 i`* Re: Accessing The Command Line3Lawrence D'Oliveiro
4 Jul 24 i +- Re: Accessing The Command Line1Rod Kay
4 Jul 24 i `- Re: Accessing The Command Line1Dmitry A. Kazakov
4 Jul 24 +* Re: Accessing The Command Line3Jeffrey R.Carter
5 Jul 24 i`* Re: Accessing The Command Line2Lawrence D'Oliveiro
5 Jul 24 i `- Re: Accessing The Command Line1J-P. Rosen
4 Jul 24 +- Re: Accessing The Command Line1Dmitry A. Kazakov
4 Jul 24 `* Re: Accessing The Command Line2Ben Bacarisse
5 Jul 24  `- Re: Accessing The Command Line1Paul Rubin

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal