Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>acceptat() keyboard input at a screen location apndxj.prg</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
AcceptAt()     Keyboard input at a screen location     Apndxj.prg


Syntax:        AcceptAt(<row>, <col>, <prompt>)

Arguments:     <row> is the screen row position of the <prompt>.

               <col> is the screen column position of the <prompt>.

               <prompt> is a character string to display prior
               getting keyboard input.

Returns:       A character string.

Description:   AcceptAt() emulates the ACCEPT command allowing the input
               of printable characters from the keyboard beginning at a
               specified screen location.  AcceptAt() displays the
               specified <prompt> and then accepts keyboard input until
               Return is pressed.  It then returns the keyboard input as
               a character string.

               This is used primarily to GET keyboard entry within SET
               KEY procedures activated during READs.  Clipper does not
               support nested READs thereby prohibiting GETting keyboard
               entry from a specified screen location.  ACCEPT is not
               particularly useful as an alternative since it performs a
               carriage return/line feed getting input.


----------------------------------- Example --------------------------------

   var = AcceptAt(12, 12, "Enter: ")
   ? var


--------------------------------- Source Code ------------------------------

   FUNCTION AcceptAt
   PARAMETERS row, col, prompt
   PRIVATE char, string

   STORE "" TO char, string
   @ row, col SAY prompt

   DO WHILE .T.

      char = INKEY(0)

      DO CASE
      CASE char = 13
         *
         * Return key.
         EXIT
      CASE char > 31 .AND. char < 127
         *
         * Printable characters.
         string = string + CHR(char)
         @ ROW(), COL() SAY CHR(char)
      CASE (char = 8 .OR. char = 19) .AND. LEN(string) > 0
         *
         * Backspace or Leftarrow keys.
         @ ROW(), COL() - 1 SAY " "
         @ ROW(), COL() - 1 SAY ""
         string = SUBSTR(string, 1, LEN(string) - 1)
      ENDCASE

   ENDDO

   RETURN string


See Also: ACCEPT

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson