with Ada.Text_IO;
with Ada.Environment_Variables;
 
procedure Env is
   package IO renames Ada.Text_IO;
   package EV renames Ada.Environment_Variables;
begin
   IO.Put_Line (Item => "Environment_Variables test");   
   EV.Set (Name  => "Foo",
           Value => "This is Foo");
   IO.Put_Line (Item => EV.Value (Name => "Foo"));
   EV.Clear (Name => "Foo");
   IO.Put_Line (Item => EV.Value (Name => "Foo"));
 
exception
   when Constraint_Error =>
      IO.Put_Line (Item => "Environment variable Foo does not exist");
end Env;
with Ada.Text_IO;
with Ada.Environment_Variables;
 
procedure Env is
   package IO renames Ada.Text_IO;
   package EV renames Ada.Environment_Variables;
begin
   IO.Put_Line (Item => "Environment_Variables test");
   EV.Set (Name  => "Foo",
           Value => "This is Foo");
   IO.Put_Line (Item => EV.Value (Name => "Foo"));
 
   EV.Set (Name  => "Bar",
           Value => "This is Bar");
   IO.Put_Line (Item => EV.Value (Name => "Bar"));
 
   EV.Clear;
 
   if not EV.Exists (Name => "Foo") and not EV.Exists (Name => "Bar") then
      IO.Put_Line (Item => "Foo and Bar are both gone!");
   end if;
end Env;

Go back


Navigation