Hello Everyone....
I have been using Turbo Pascal up to version 7 for DOS and Borland Delphi 7 up until the advent of Windows 7. I have recently started using Free Pascal and although I have am glad to have written some new programs in FP and recompile some programs I wrote using Turbo Pascal 7, I have been having issues recompiling and using programs that use Graphic rather than Text format. They compile but I find I have to switch to a second window to enter anything from the keyboard. It may be a noobie error or I have made a stooopid but I hope you'll not be angry with me and send a squad of trolls to my house to beat me up and skin my pet ferrit.
I have been using the following procedure to read from the keyboard and write the input to a graphic screen which worked fine up to Turbo Pascal 7. However, I did not write this code and don't know how to amend it for it to work under FP. I hope someone would be kind enough to revise it for me.
Thank you all in advance.
Weosule
PROCEDURE ReadlnXY(X, Y: Integer; VAR S: String);
{$V-} {Relax string checking}
VAR
Ch: Char; { key from keyboard }
Done: boolean; { our flag for quiting }
CurColor: word; { color to write text in }
OldX: Integer; { old x }
BEGIN
S := '';
CurColor := GetColor;
MoveTo(X, Y);
Done := False;
WHILE NOT Done DO
BEGIN
Ch := Readkey; { get a single key }
CASE Ch of
#0: { extra key - two chars - let's ignore them }
Ch := Readkey;
#13: { return key }
Done := true; { we got our string, let's go }
#32..#126: { ASCII 32 (space) through 126 (tilde) }
BEGIN
OutText(Ch);
S := Concat(S, Ch);
END;
#8: IF Length(S) > 0 THEN
BEGIN
{ move back to last character }
OldX := GetX - TextHeight(S[Length(S)]);
MoveTo(OldX, GetY);
{ over write last character }
SetColor(0);
OutText(S[Length(S)]);
SetColor(CurColor);
MoveTo(OldX, GetY);
{ remove last character from the string }
Delete(S, Length(S), 1);
END;
END;
END;
END; { ReadlnXY }