num() function

The num() function evaluates an expression and returns 1 (true) if it is a decimal numeric. Otherwise, it returns 0, if the expression contains any nonnumeric characters.

Syntax

num(exp)

Parameter(s)

exp Expression to test. If it is a decimal numeric, 1 (true) is returned. If it contains any nonnumeric characters, 0 is returned.

Description

The empty, or null string ("") is considered to be a numeric string.

The strings below are considered to be numeric, and return a 1:

  • . (period)

  • - (minus)

  • + (plus)

  • -. (minus/period)

  • +. (plus/period)

Example(s)

This loop terminates when a numeric response is entered for the variable number.

loop
input number
until num(number) do repeat