Function GetPlayersName: String;
Var
PlayerName: String;
i: Integer;
Begin
Write('What is your name? ');
Readln(PlayerName);
for i := 1 to length(PlayerName) do
begin
PlayerName[i] := Upcase(PlayerName[i]);
if not(PlayerName[i] in ['A' .. 'Z']) AND (PlayerName[i] <> ' ') then
begin
writeln('Letters and spaces please');
end;
end
else
GetPlayersName := PlayerName;
end;
For some reason, during the above validation, the else
statement won't compile. Here is the error message:
[dcc32 Error] AQA_Reverse.dpr(125): E2029 'END' expected but 'ELSE' found
As well as this, when the message is printed, it prints by the number of characters and I don't know how to change it.