WAITKEY

Purpose:

Pauses execution of an SPL function until a key is pressed.

Syntax:

WAITKEY

Example:

Assume the following function definition, power, is loaded.

 

/* raise x to the n-th power for n > 0 */
power(x, n)
{
    for (p = 1; n > 0; --n)
    {
        echo(p);
        waitkey;
 
        p = p * x;
    }
 
    return(p);
}

 

Then, type the following at the command line:

 

power(2, 8)

 

The value 1 is returned, and the power function pauses until any key is pressed. Pressing the spacebar after each new value is displayed steps through the loop, and displays the following series of intermediate values for the variable, p: 1, 2, 4, 8, 16, 32, 64, 128, 256. 2 raised to the 8th power (i.e. 28) equals 256.

Remarks:

The WAITKEY function is useful for debugging and testing custom SPL functions.

 

The WAITKEY function is similar to the command file keyword @WAITKEY.

 

See DEBUG to invoke the SPL debugger.

See Also:

@PAUSE in Command File Functions

DEBUG

PAUSE