Sujet : Re: Accessing The Command Line
De : spam.jrcarter.not (at) *nospam* spam.acm.org.not (Jeffrey R.Carter)
Groupes : comp.lang.adaDate : 04. Jul 2024, 13: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 Style186