Newsgroups: comp.lang.pascal
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!cunixf.cc.columbia.edu!cunixb.cc.columbia.edu!stone
From: stone@cunixb.cc.columbia.edu (Glenn Stone)
Subject: Reading characters in graphics mode
Message-ID: <1991Jun14.150309.5126@cunixf.cc.columbia.edu>
Sender: usenet@cunixf.cc.columbia.edu (The Network News)
Nntp-Posting-Host: cunixb.cc.columbia.edu
Reply-To: stone@cunixb.cc.columbia.edu (Glenn Stone)
Organization: Columbia University
Date: Fri, 14 Jun 1991 15:03:09 GMT

There must an easy way to do this but I seem to have a mental block.  
I'm writing a graphics mode equivalent of READLN(StringVariable) in
TP 5.5.  This loop reads characters and tacks them onto a string
called T.  The problem is in dealing with the backspace; I want the
pointer to back up and erase the last character, but the ' ' in
graphics mode doesn't do this.  I need the equivalent of ClrEol.
How do you do it?  Thanks in advance...

   done := false;
   t := '';
   repeat
      c := ReadKey;
      case c of
         #13 : done := true;                             { CR }
         #8  : begin                                     { backspace }
               OutTextXY(GetX-TextWidth(t[length(t)]),GetY,' ');
               delete(t,length(t),1);                       ^----here
               end;                                                
         else begin                                    { append char }
            t := t + c;
            MoveTo(x,y);
            OutText(t);
            end;
         end;
   until done;

-------------------------------------------------------------------------
  Glenn Stone                                      BITNET: stone@cunixc
  Columbia University            INTERNET: stone@cunixb.cc.columbia.edu
-------------------------------------------------------------------------



