WAIT

WAIT*

Suspend program processing until a key is pressed

Syntax

      WAIT [<expPrompt>] [TO <idVar>]

Arguments

<expPrompt> is an expression of any data type displayed as a prompt. If no <expPrompt> is specified, the default prompt displayed is: “Press any key to continue…”

TO <idVar> is the variable, of any storage class, that holds the value of the key pressed as a character value. If <idVar> does not exist or is not visible, it is created as a private variable and then assigned the character value.

Description

WAIT is a console command and wait state that displays a prompt after sending a carriage return/line feed to the screen. It then waits for the user to press a key. If the TO clause is specified, <idVar> is assigned the keystroke as a character value. If an Alt or Ctrl key is pressed, WAIT assigns CHR(0) to <idVar>. Non-alphanumeric values entered by pressing an Alt-keypad combination assign the specified character. If the character can be displayed, it is echoed to the screen. Function keys are ignored unless assigned with SET FUNCTION or SET KEY.

WAIT is a compatibility command and, therefore, is not recommended for general usage. It is superseded by both @…GET/READ and INKEY() for getting single character input.

Notes

. WAITing without a prompt: To pause execution without displaying a prompt, specify WAIT, null string (“”), or INKEY(0). The latter is recommended since it does not disturb the current screen cursor position.

Examples

      .  This example illustrates how to store the WAIT keystroke as an
         array element:

      aVar := ARRAY(6)

      WAIT "Press a key..." TO aVar[1]
      ? aVar[1]                  // Result: key pressed in
                                 // response to WAIT
      ? aVar[2]                  // Result: NIL
      ? VALTYPE(aVar)            // Result: A
      ? VALTYPE(aVar[1])         // Result: C

Seealso

@…GET, ACCEPT*, INKEY(), INPUT*, MENU TO

Advertisements

SET TYPEAHEAD

SET TYPEAHEAD

Set the size of the keyboard buffer

Syntax

      SET TYPEAHEAD TO <nKeyboardSize>

Arguments

TO <nKeyboardSize> specifies the number of keystrokes the keyboard buffer can hold from a minimum of zero to a maximum of 4096. The default size of the keyboard buffer is machine-dependent but 16 is the minimum size.

Description

SET TYPEAHEAD defines the size of the Clipper keyboard buffer that caches keystrokes input directly by the user. SET TYPEAHEAD, however, does not affect the number of characters that can be stuffed programmatically using the KEYBOARD command. When executed, SET TYPEAHEAD clears the keyboard buffer and sets the size to <nKeyboardSize>.

When TYPEAHEAD is SET TO zero, keyboard polling is suspended. An explicit request for keyboard input, however, will temporarily enable the keyboard and read any pending keystrokes from the BIOS buffer. Calling NEXTKEY() constitutes such an explicit request. NEXTKEY() reads any pending keystrokes from the BIOS buffer and returns the INKEY() value of the first keystroke read, or zero if no keystrokes are pending.

Seealso

ALTD(), CLEAR, TYPEAHEAD, INKEY(), KEYBOARD, NEXTKEY()

DISPLAY

DISPLAY

Display records to the console

Syntax

      DISPLAY <exp list>
             [TO PRINTER] [TO FILE <xcFile>]
             [<scope>] [WHILE <lCondition>]
             [FOR <lCondition>] [OFF]

Arguments

<exp list> is the list of values to display for each record processed.

TO PRINTER echoes output to the printer.

TO FILE <xcFile> echoes output to the indicated file which can be specified either as a literal file name or as a character expression enclosed in parentheses. If an extension is not specified, .txt is added.

<scope> is the portion of the current database file to DISPLAY. The default is the current record, or NEXT 1. If a condition is specified, the scope becomes ALL.

WHILE <lCondition> specifies the set of records meeting the condition from the current record until the condition fails.

FOR <lCondition> specifies the conditional set of records to DISPLAY within the given scope.

OFF suppresses the display of the record number.

Description

DISPLAY is a database command that sequentially accesses records in the current work area, sending the results of the <exp list> to the console in a tabular format with each column separated by a space. The command does not display column headers or pause at predetermined intervals. DISPLAY is identical to LIST with the exception that its default scope is NEXT 1 rather than ALL.

When invoked, output is sent to the screen and optionally to the printer and/or a file. To suppress output to the screen while printing or echoing output to a file, SET CONSOLE OFF before the DISPLAY command line.

Notes

. Interrupting output: To let the user interrupt the processing of a DISPLAY command, using the INKEY() function, add a test for the interrupt key press to the FOR condition. See the example below. . Printer margin: Since DISPLAY is a console command, it honors the current SET MARGIN for output echoed to the printer.

Examples

      .  This example illustrates a simple DISPLAY, and a conditional
      DISPLAY to the printer:
      USE Sales NEW
      DISPLAY DATE(), TIME(), Branch
      DISPLAY Branch, Salesman FOR Amount > 500 TO PRINTER
      .  This example interrupts a DISPLAY using INKEY() to test
      whether the user pressed the Esc key:
      #define K_ESC  27
      USE Sales INDEX SalesMan NEW
      DISPLAY Branch, Salesman, Amount WHILE ;
         INKEY() != K_ESC

Seealso

DBEVAL(), INKEY(), LIST, SET MARGIN

ACCEPT

ACCEPT*

Place keyboard input into a memory variable

Syntax

      ACCEPT [<expPrompt>] TO <idVar>

Arguments

<expPrompt> is an optional prompt displayed before the input area. The prompt can be an expression of any data type.

<idVar> is the variable that will hold input from the keyboard. If the specified <idVar> does not exist or is not visible, a private variable is created.

Description

ACCEPT is a console command and wait state that takes input from the keyboard and assigns it as a character string to the specified variable. When ACCEPT is executed, it first performs a carriage return/linefeed, displays the prompt, and then begins taking characters from the keyboard at the first character position following the prompt. You may input up to 255 characters. When input reaches the edge of the screen, as defined by MAXCOL(), the cursor moves to the next line.

ACCEPT supports only two editing keys: Backspace and Return. Esc is not supported. Backspace deletes the last character typed. Return confirms entry and is the only key that can terminate an ACCEPT. If Return is the only key pressed, ACCEPT assigns a null value (“”) to <idVar>.

Examples

      .  This example uses ACCEPT to get keyboard input from the user:
      LOCAL cVar
      ACCEPT "Enter a value: " TO cVar
      IF cVar == ""
         ? "User pressed Return"
      ELSE
         ? "User input:", cVar
      ENDIF

Seealso

@…GET, @…SAY, INKEY(), INPUT*, KEYBOARD, WAIT*

Chr()

 

CHR()

Converts an ASCII value to it character value

Syntax

      CHR( <nAsciiNum> )  --> cReturn

Arguments

<nAsciiNum> Any ASCII character code.

Returns

<cReturn> Character expression of that ASCII value

Description

This function returns the ASCII character code for <nAsciiNum>. The number expressed must be an integer value within the range of 0 to 255 inclusive. The CHR() function will send the character returned to whatever device is presently set.

The CHR() function may be used for printing special codes as well as normal and graphics character codes.

Examples

      ? CHR( 32 )
      ? chr( 215 )

Compliance

Clipper

Platforms

All

Files

Library is rtl

Seealso

ASC(), INKEY()