ada

Ada: Adding an exception in a separate procedure when reading a file

旧时模样 提交于 2019-12-25 05:11:23
问题 This is a follow-up of this question: Ada: reading from a file . I would like to add an exception that checks if the file that I'm opening actually exists or not. I have made a separate procedure to avoid code clutter. Here is the main code test_read.adb : with Ada.Text_IO; use Ada.Text_IO; with Ada.Long_Float_Text_IO; with Ada.Float_Text_IO; procedure Test_Read is Input_File : File_Type; Value : Long_Float; procedure Open_Data (File : in Ada.Text_IO.File_Type; Name : in String) is separate;

GNAT Programming Suite - source file not found

二次信任 提交于 2019-12-25 02:37:29
问题 Ada is still new to me, so I am trying to find my way around the GPS IDE. I asked another question earlier, but I think this problem has precedence over that one, and may be at the root of my trouble. When I compile, I am getting a long list of *warning: source file ... not found" In my .gpr file, I have listed all of the spec and body source files and use the following naming scheme: package Naming is for Casing use "mixedcase"; for Dot_Replacement use "."; for Spec_Suffix ("ada") use "_s

Ada Array store unbounded String getting from .txt file

怎甘沉沦 提交于 2019-12-24 21:49:01
问题 Im having a trouble storing unbounded string to an array if I'mm getting it to .txt file. Here is my hardcoded data: Data : An_Array := (1 => (Name => +"9 - Joe"), 2 => (Name => +"8 - Trisha "), 3 => (Name => +"7 - RR "), 4 => (Name => +"6 - Jane "), 5 => (Name => +"5 - Doe ")); What if I want to get the data from a .txt file? with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; with Ada.Containers.Generic_Array_Sort; procedure Main is function "+" (S :

How do I compile ASIS for GNAT on 7.4?

假装没事ソ 提交于 2019-12-24 20:23:33
问题 I've downloaded the code from the repository here, and have run the make command after reading the README file (which is quite long, so I probably missed some things in it). I'm getting a build error, the source of which is not altogether clear. The make process terminates in the following: compilation of asis-data_decomposition-set_get.adb failed compilation of asis-text.adb failed compilation of a4g-contt-dp.adb failed gprbuild: *** compilation phase failed See this pastebin for the full

Clearing the keyboard buffer in Ada

荒凉一梦 提交于 2019-12-24 09:58:42
问题 I wrote a function to clear the keyboard buffer, since I think I am having leftover input after a get, but it's just taking input forever. here is the get(String(1..10) --getString10-- procedure getString10(s : in out string10) is Last: Integer; begin s := (others => ' '); Get_Line(S, Last); end getString10; and here is the flush I made, pretty much copied from a wiki on clearing keyboard buffers --flush-- procedure flush is char : character; more : boolean; begin loop get_immediate(char,

Ada: Seeding Random

有些话、适合烂在心里 提交于 2019-12-24 02:58:09
问题 How can I seed Ada.Numerics.Discrete_Random with a discrete value? I see code like: declare type Rand_Range is range 25..75; package Rand_Int is new Ada.Numerics.Discrete_Random(Rand_Range); seed : Rand_Int.Generator; Num : Rand_Range; begin Rand_Int.Reset(seed); Num := Rand_Int.Random(seed); Put_Line(Rand_Range'Image(Num)); end; which seeds the "Rand_Int" with the "seed" value, but I cannot find any instruction on actually setting the seed value. Or I am completely looking at this the wrong

Ada: How to check if input is an enumeration type [duplicate]

回眸只為那壹抹淺笑 提交于 2019-12-24 01:39:17
问题 This question already has answers here : Compare a string input to an Enumerated type (3 answers) Closed 2 years ago . I am reading input from the keyboard. The input is supposed to match one of the elements defined in an enumeration type. Here is an example of the enum type: type NameType is (Bob, Jamie, Steve); If I receive an input that is not one of these 3, ada raises an IO exception. How do I handle this to where I can simply display a "try again" message and not have the program stop?

Passing a C++ array to Ada95

纵然是瞬间 提交于 2019-12-23 21:09:20
问题 I'm trying to pass an array of unsigned integers from C++ to Ada. The Ada Lovelace tutorial states that an Ada array corresponds to a pointer to the first element of an array in C++. Here is what I'm trying to do. C++ unsigned int buffer[bufferSize]; ... unsigned int* getBuffer() { return buffer; } Ada pragma Import (C, C_Get_Buffer, "getBuffer"); ... function C_Get_Buffer returns System.Address; ... Buffer : array (1 .. Buffer_Size) of Interfaces.C.Unsigned; ... Buffer'Address := C_Get

what is the standard ada include path

烂漫一生 提交于 2019-12-23 19:05:38
问题 Im using gnat4.6 on Ubuntu installed using apt-get. I need to know where to install downloaded libraries like APQ. What should I set my ADA_INCLUDE_PATH and ADA_OBJECTS_PATH to? 回答1: The beauty of Ada support in Debian (on which Ubuntu is based) is that you don't need to mess with ADA_INCLUDE_PATH and friends; supported libraries are installed where the GNAT Project Manager expects to find them. Say gnatls -v to see the default values. To use the system as intended, you will find it much

Ada: cmake and PLplot installation on Windows

风流意气都作罢 提交于 2019-12-23 18:31:56
问题 This is a follow-up of the post at Ada: plotting 2d graphs . I decided to create a new post as this is a separate issue. The installation of PLplot for Windows is at: http://www.miscdebris.net/plplot_wiki/index.php?title=Specifics_for_various_platforms#Windows . The installation is as follows: cd plplot mkdir buildmingw cd buildmingw cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=install .. mingw32-make mingw32-make install I decided to go for the MinGW instillation by downloading the exe