I have a string passed into a function, I would like to compare the first character of the string against a number.
I.E. if String(1) = "3" then When I compile I get:
warning: index for String may assume lower bound of 1 warning: suggested replacement String'First + 1 I would really like to make this right, but when I try "first" it actually grabs a number, not the character.
Is there a better way to do it?
I tried looking up the 'First concept, and the below site explains I'm actually getting the number of the index, not the actual contents: http://en.wikibooks.org/wiki/Ada_Programming/Types/array
For example,
Hello_World : constant String := "Hello World!"; World : constant String := Hello_World (7 .. 11); Empty_String : constant String := ""; Using 'First I'll get:
Array 'First 'Last 'Length 'Range Hello_World 1 12 12 1 .. 12 World 7 11 5 7 .. 11 Empty_String 1 0 0 1 .. 0 Based on that information, I can't get H from Hello world (for a comparison like if Hello_World(1) = "H" then)
EDIT: So the way I initially was doing it was (insert some variable name instead of string in this case)
String(String'First .. String'First) = "1" So that works from what I can tell, however, rather then writing all that, I found out that
String(String'First) = '1' Does the same thing but using char comparison, which makes a lot more sense!
Thanks for all the answers everyone!