comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not>
Subject: Re: Accessing The Command Line
Date: Thu, 4 Jul 2024 13:27:05 +0200	[thread overview]
Message-ID: <v660u9$2nt74$1@dont-email.me> (raw)
In-Reply-To: <v64p6n$2dviq$1@dont-email.me>

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

  parent reply	other threads:[~2024-07-04 11:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-04  0:08 Accessing The Command Line Lawrence D'Oliveiro
2024-07-04  1:16 ` Paul Rubin
2024-07-04  1:50   ` Lawrence D'Oliveiro
2024-07-04 15:13     ` Rod Kay
2024-07-04 16:15     ` Dmitry A. Kazakov
2024-07-04 11:27 ` Jeffrey R.Carter [this message]
2024-07-04 23:54   ` Lawrence D'Oliveiro
2024-07-05  8:58     ` J-P. Rosen
2024-07-04 13:01 ` Dmitry A. Kazakov
2024-07-04 19:42 ` Ben Bacarisse
2024-07-04 22:06   ` Paul Rubin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox