Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Clipper Tools One Guide - <b>xtoc()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
XTOC()

Syntax:     XTOC(<expX>)

Arguments:  <expX> can be an expression of any data type.

Returns:    A character string.
            Supplies a character string corresponding to the <expX>
            argument.

Usage:      At first sight it would appear that the XTOC() function cannot
            accomplish anything that could not be achieved with other
            functions.  However, it has the crucial advantage that it is
            not necessary to take into consideration the data type of an
            argument concerned.  It is therefore possible to convert the
            data in each field to a string using a loop.  These can then
            be linked into a long string which may be used for indexing
            or to make comparisons.  Each data type will always produce
            a string with a fixed length.

            Data type           Result length
            ---------           -------------
            Numbers               8
            Logic                 1
            Date                  8
            String               Unchanged

Notes:      Please note that index keys cannot be longer than 250
            characters.

Library:    CT1.LIB


--------------------------------- Example ------------------------------

Examples:   * XTOC() operates like LTOC() with Logic
            * arguments.
            ? XTOC(.T.)                         && "T"
            ? XTOC(.F.)                         && "F"

            * Numerical values will always produce a
            * string 8 bytes long.
            ? XTOC(0)                           && Length 8
            ? XTOC(9.9)                         &&      "
            ? XTOC(-9.9)                        &&      "
            ? XTOC(99)                          &&      "
            ? XTOC(9.9)                         &&      "
            ? XTOC(-99)                         &&      "

            * A string will produce the same string again.
            ? XTOC("123ABCabc")                 && "123ABCabc"

            * A date will produce an ANSI date.
            ? XTOC(CTOD("12/31/99"))            && "19991231"
            ? XTOC(CTOD("01/01/00"))            && "19000101"

            * A blank or incorrect date will produce a
            * blank string.
            ? XTOC(CTOD("  .  .  "))            && "        "
            ? XTOC(CTOD("77.77.77"))            && "        "

            * The function combines all fields of a
            * database into a single string.  In this way
            * it is possible to compare two data sets
            * completely with each other.

            FUNCTION StringRec
            PRIVATE i, num_fields, a_field, StringRec

            StringRec = ""
            num_fields = FCOUNT()               && Number of fields

            FOR i = 1 TO num_fields
               a_field = FIELD(i)               && The field name
               StringRec = StringRec + XTOC(&a_field)
            NEXT i

            RETURN StringRec



Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson