title: Assign CLI argument to a string variable in Ada
body: <p>I am having some issues when attempting to assign a command line argument to an ada program to a string variable.</p>
  
  <p>here is my main procedure:</p>
  
  <pre><code>with Ada.Command_Line; use Ada.Command_Line;
  
  procedure proc is
      cli_exception : exception;
      filename : String (1..Argument(1)'length);
      usage : String (1..31);
  begin
      usage := "Usage: ./proc [filename]";
  
     if Argument_Count /= 1 then
         raise cli_exception;
     end if;
  
     for arg in 1..Argument_Count loop
         case arg is
             when 1 =&gt;
                 filename := Argument(arg);
             when others =&gt;
                 null;
         end case;
     end loop;
  
     put_line("filename is: " &amp; filename);
  exception
      when e: cli_exception =&gt;
          put_line(usage);
  end proc;
  </code></pre>
  
  <p>The problem here is in the declarative part of the procedure where the upper bound to the string "filename" is set. If no CLI arguments are given, then Argument(1) will throw an exception before the procedure even begins because there is no argument #1.</p>
  
  <p>The output is:</p>
  
  <pre><code>raised CONSTRAINT_ERROR : a-comlin.adb:65 explicit raise
  </code></pre>
  
  <p>Is there any other way of defining the size of that string variable without using an unbounded string, and without picking an arbitrary number (as fully qualified filenames can get quite large)?</p>
  
  <p>-Thanks</p>