Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7921083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:27:15+00:00 2026-06-03T16:27:15+00:00

I am dealing with an array whose length is determined during the execution of

  • 0

I am dealing with an array whose length is determined during the execution of the program. So I am making use of a block statement in which I can set the limits of the array.

I am having problems to write the elements of the array to a file as I was using a stub for the write procedure. I removed the stub to have everything in the same code. Though now my code compiles and run, it is not writing to the file. Here is the code:

with Ada.Float_Text_IO;
with Ada.Integer_Text_IO;
with Ada.Text_IO; 


procedure Compute_Parameters is

Spin_Speed, Whirling_Speed        : Float;
Time_Step, Rotor_Revolutions      : Float;
Number_Of_Steps                   : Float;


begin
Ada.Text_IO.Put("Enter the spin speed ");
Ada.Float_Text_IO.Get (Item => Spin_Speed);
Ada.Text_IO.New_Line (1);
Ada.Text_IO.Put("Enter the whirling speed ");
Ada.Float_Text_IO.Get (Item => Whirling_Speed);
Ada.Text_IO.New_Line (1);
Ada.Text_IO.Put("Enter the time step ");
Ada.Float_Text_IO.Get (Item => Time_Step);
Ada.Text_IO.New_Line (1);
Ada.Text_IO.Put("Enter the number of revolutions of the rotor ");
Ada.Float_Text_IO.Get (Item => Rotor_Revolutions);


Number_Of_Steps := (360.0 / (Time_Step * Whirling_Speed)) * Rotor_Revolutions *  (Whirling_Speed / Spin_Speed);


declare

   type Vector is array (Integer range <>) of Float;
   Time_Vector                     : Vector (1 .. Integer (Float'Truncation (Number_Of_Steps)) + 1);
   Rotor_Position_Degrees          : Vector (1 .. Integer (Float'Truncation (Number_Of_Steps)) + 1);

   Count       : Integer := 0;
   Start       : Float := 0.0;
   Step        : Float := Time_Step;

   Output_Data_File                            : File_Type;

   procedure Write_Files (Output_File          : File_Type;
                          Out_1                   : Integer;
                          Out_2                   : Float;
                          Prec                    : Natural := 5
                          ) is 
   begin
      Ada.Integer_Text_IO.Put (File => Output_File, Item => Out_1);
      Ada.Text_IO.Put (Output_File, "   ");
      Ada.Float_Text_IO.Put (File => Output_File, Item => Out_2, Fore => 6, Aft => Prec, Exp => 0);
      Ada.Text_IO.New_Line (Output_File);
   end Write_Files;



 begin -- begin of Declare

     Ada.Text_IO.Put ("Put file name to write: ");
     Create (Output_Data_File, Out_File, Get_Line);


     for I in 1 .. Time_Vector'Length  loop
         Count := Count + 1;
         Time_Vector(I) := Start + Step * Float(I-1);
         Put (Integer'Image(Count));
         Ada.Text_IO.Put("   ");
         Rotor_Position_Degrees(I) := Spin_Speed * Time_Step * Float(I-1);
         Ada.Float_Text_IO.Put (Item => Rotor_Position_Degrees(I), Fore => 5, Aft  => 1, Exp  => 0);
         Ada.Text_IO.New_Line(1);

         --write to file
         Write_Files (Output_Data_File,
                      Out_1 => Count,
                      Out_2 => Rotor_Position_Degrees(I)
                      );
     end loop;

 close(Output_Data_File);


 end; -- end of Declare


end Compute_Parameters;

I notice that the 2 lines just after begin in Declare are not being executed at all:

Ada.Text_IO.Put ("Put file name to write: ");
Create (Output_Data_File, Out_File, Get_Line);

What am I doing wrong?

Thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:27:17+00:00Added an answer on June 3, 2026 at 4:27 pm

    Pressing return after your last Get for Rotor_Revolutions has left an empty line in standard input, which remains to be read:

     Ada.Text_IO.Put_Line (Ada.Text_IO.Get_Line);
     Ada.Text_IO.Put ("Put file name to write: ");
     Create (Output_Data_File, Out_File, Ada.Text_IO.Get_Line);
    

    Just to clarify: It’s the Get_Line that’s required; the Put_Line is just to show that it’s an empty line.

    Alternatively, use Ada.Command_Line, as shown in this example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an asbolute nightmare dealing with an array of numbers which has the
I have this method dealing with a couple array that I can't seem to
Dealing with Java - which the option you prefer in the most cases -
When dealing with a series of numbers, and wanting to use hash results for
I am dealing with a set of native functions that return data through dynamically-allocated
I've been dealing a lot lately with abstract classes that use generics. This is
So I don't think I'm making full use of the foreach loop. Here is
I believe I may be dealing with some view issues which are not allowing
A shortcut I often use in C when dealing with embedded APIs (communications protocols,
I am dealing with a dynamic form that can potentially provide the user with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.