Search                        Top                                  Index
HELP STRNUMBER                                  Aaron Sloman June 1990

    strnumber(<string or word>) -> number or false

This procedure takes a string or word containing the character codes for
an number, and returns a number. If the string does not contain
appropriate characters for a number as recognised by the itemiser
(leading or trailing spaces are ignored), or if the string is empty, the
result is FALSE. E.g.:

    strnumber('1234') =>
    ** 1234

    strnumber(' -1234.5') =>
    ** -1234.5

    strnumber('twenty') =>
    ** <false>

    strnumber("'32'") =>
    ** 32

    strnumber("cat") =>
    ** <false>

Thus STRNUMBER can also be used to TEST whether a string or word
contains characters appropriate for a number.

If applied to anything but a string or word it will cause a mishap.

strnumber is useful if -unpackitem- is used to transform a word into
a list of words and you want to get numbers back. E.g.

    unpackitem("cat3") =>
    ** [c a t 3]

The last element is a WORD not a number, but strnumber can be used to
convert it.


See also
HELP * STRINGIN
HELP * STRINGS
HELP * WORDS
HELP * MATH
HELP * UNPACKITEM


--- C.all/help/strnumber
--- Copyright University of Sussex 1990. All rights reserved. ----------