Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper Tools . Books 1-3 - <b>xtoc()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 XTOC()
 Converts an expression of any data type into a string
------------------------------------------------------------------------------
 Syntax

     XTOC(<expValue>) --> cValue

 Argument

     <expValue>  Designates an expression of any desired data type.

 Returns

     XTOC() returns a character string version of the <expValue> parameter.

 Description

     At first glance, the XTOC() function does not appear to accomplish
     anything that cannot be done with the other functions.  However, the
     advantage lies in the fact that you do not have to pay attention to the
     input data types.  For example, you can convert the data in every field
     within a loop into a string.  You could then link these into a longer
     string and use them to index or for comparisons.

     Each data type always returns a string with a particular fixed length:

     Table 13-9: Resulting String
     ------------------------------------------------------------------------
     Data Type    Result Length
     ------------------------------------------------------------------------
     Numeric      8
     Logical      1
     Date         8
     String       Unchanged
     ------------------------------------------------------------------------

 Note

     .  The index string cannot be longer than 256 characters.

 Examples

     .  In the case of logical parameters, XTOC() works like LTOC():

        ? XTOC(.T.)                              // "T"
        ? XTOC(.F.)                              // "F"

     .  Numeric values always return an 8-byte string:

        ? XTOC(0)                                // Length 8
        ? XTOC(9.9)                              // Ditto
        ? XTOC(-9.9)                             // Ditto
        ? XTOC(99)                               // Ditto
        ? XTOC(-99)                              // Ditto

     .  A string returns the same string:

        ? XTOC("123ABCabc")                      // "123ABCabc"

     .  A date returns the ANSI date:

        ? XTOC(CTOD("12/31/99"))                 // "19991231"
        ? XTOC(CTOD("01/01/00")                  // "19000101"

     .  An empty or false date returns an empty string rather than a
        null string:

        ? XTOC(CTOD("  /  /  ")                  // "        "
        ? XTOC(CTOD("77/77/77")                  // "        "

     .  Show a function where all the fields in a database are
        combined into one string.  This way, you can do a complete comparison
        of the two data strings:

        FUNCTION STRINGREC
           PRIVATE nI, nFieldNo, cField, cStringRec
           cStringRec := ""
           nFieldNo   := FCOUNT()                // Number of fields
           FOR nI = 1 to nFieldNo
             cField          := FIELD(nI)        //  Field name
             cStringRec := cStringRec + XTOC(&cField)
           NEXT nI
           RETURN (cStringRec)


See Also: CTOF()

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