Hi all.
I was just wondering if there is a more efficient way of writing this:
Case Nextguessedletter of
'A': Count:= 1
'B': Count:= 2
'C' etc
'D' etc
'E'
'F'
'G'
'H'
'I'
'J'
'K'
'L'
'M'
'N'
'O'
'P'
'Q'
'R'
'S'
'T'
'U'
'V'
'W'
'X'
'Y'
'Z'
The thing is, I want to store the letters of the alphabet into an array 1..26.
Thanks
Ok. Nvm. I found out how to do it. For anyone who wants to know:
I just used this function called Succ. It takes the next character in series. Ie:
Succ('A') will give: B
Succ('2') will give: 3
Thanks
Check out the Ord() function as well. Ord(val)-Ord('A')+1.
const
Letters : ABCDEFGHIJKLMNOPQRSTUVWXYZ;
var
i: Byte;
s: char;
begin
s := 'b';
i := Pos(UpperCase(s), Nextguessedletter); //Return 2
end;
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks