0

Currently, i am working with some exercises with Pascal's unit. I try to create my own Readln but unsuccessful.

Unit DOCXAU;
INTERFACE
uses crt;
       TYPE  xau= STRING[100];
      var  c : char;
        s : xau;
        
       function nhap : xau;
IMPLEMENTATION
       function nhap : xau;
                   begin
                     s:='';
                     repeat
                     c:=ReadKey;
                     if ((c=#8) and (s<>''))       then
                        begin
                             delete(s,length(s),1);
                         end;
                     if ((c<>#8) and (c<>#13)) then
                        begin
                             write(c);
                             s:=s+c
                        end;
                     until c=#13;
                        nhap:=s;
                   end;
END.

Otherwise the final result is acceptable but when backspacing the cursor goes back with undeleted character.

Really needs suggestions..

Thanks in advance

Daravuth KEU

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Micheus
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.