Hello, I'm trying to follow a standard reference for opening files but running into a constraint_error at the line when I call Ada.Text_IO.Create(). It says "range check failed". Any help appreciated, here's the code:
WITH Ada.Text_IO;
WITH Ada.Integer_Text_IO;
USE Ada.Text_IO;
USE Ada.Integer_Text_IO;
PROCEDURE FileManip IS
--Variables
Start_Int : Integer;
Stop_Int : Integer;
Max_Length : Integer;
--Output File
MaxName : CONSTANT Positive := 80;
SUBTYPE NameRange IS Positive RANGE 1..MaxName;
OutFileName : String(NameRange) := (OTHERS => '#');
OutNameLength : NameRange;
OutData : File_Type;
--Array
TYPE Chain_Array IS ARRAY(1..500) OF Integer;
Sum : Integer := 1;
BEGIN
--Inputs
Ada.Text_IO.Put(Item => "Enter a starting Integer: ");
Ada.Integer_Text_IO.Get(Item => Start_Int);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put(Item => "Enter a stopping Integer: ");
Ada.Integer_Text_IO.Get(Item => Stop_Int);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put(Item => "Enter a Maximum Length to search: ");
Ada.Integer_Text_IO.Get(Item => Max_Length);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put(Item => "Enter a output file name > ");
Ada.Text_IO.Get_Line(
Item => OutFileName,
Last => OutNameLength);
Ada.Text_IO.Create(
File => OutData,
Mode => Ada.Text_IO.Out_File,
Name => OutFileName(1..OutNameLength));
Ada.Text_IO.New_Line;