[A89] Re: C question


[Prev][Next][Index][Thread]

[A89] Re: C question




----- Original Message -----
From: <GSpark1@aol.com>
To: <assembly-89@lists.ticalc.org>
Sent: Saturday, March 10, 2001 7:02 AM
Subject: [A89] Re: C question


>
> well how do you make an input to get someones name for a high score?

Taken straight from the TIGCC FAQ:

      Q: How I can get an input from the keyboard?
      A: There is a lot of method how you can make such routine. This is
quite easy if you are a C programmer. The easiest but the worst method is to
use gets function from stdio.h header file: gets does not allow any editing
facitilities (even backspace key will not work). It may be useful while the
program is in a testing state. It is recommended in any serious program to
make a custom keyboard input routine. For example, I usually used the
following routine, which is good enough for many purposes:
void InputStr (char *buffer, short maxlen)
{
  SCR_STATE ss;
  short key, i = 0;
  buffer[0] = 0;
  SaveScrState (&ss);
  do
    {
      MoveTo (ss.CurX, ss.CurY);
      printf ("%s_  ", buffer);
        // Note that two spaces are required if F_4x6 font is used
      key = ngetchx ();
      if (key >= ' ' && key <= '~' && i < maxlen) buffer[i++] = key;
      if (key == KEY_BACKSPACE && i) i--;
      buffer[i] = 0;
    } while (key != KEY_ENTER);
}


-Matthew





Follow-Ups: References: