Reputation: 15
I'm trying to make a simple looping program but get the error on line 18, subtype mark required in this context, but I don't get this error when running other programs?
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
with Ada.Text_IO.Unbounded_IO;
use Ada.Text_IO.Unbounded_IO;
procedure main is
input : Unbounded_String;
begin
while input not in "!Close" loop --Line 18
Get_Line(input);
end loop;
end main;
Upvotes: 1
Views: 780
Reputation: 6430
In a membership test, both values must be of the same type. In your case,
input
is an Unbounded_String
, while "!Close"
is a string literal.
You either have to convert one of them into the other, or just use the equality operator defined in Ada.Strings.Unbounded
(And since you've already done use Ada.Strings.Unbounded
you have visibility of all the alternatives):
while input not in To_Unbounded_String("!Close") loop --Line 18
or
while To_String(input) not in "!Close" loop --Line 18
or
while input /= "!Close" loop --Line 18
Upvotes: 2