Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- SIx Driver RDD v3.00 - Reference Guide - <b>sxchar():</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  sxChar():

  Syntax:    sxChar( [<nLen> [,<xValue>]] )

             nLen   = Optional Length to make the return value.  When used
                      as a template value for creating a new multi-key
                      index, this tells the SIx Driver how long to make the
                      key.  If no value is passed, a default of 10 is used.
             xValue = Optional value to truncate or pad the return value to.
                      If this was not a character variable coming into the
                      function, it will be converted into one on the way out.

  Returns:   A string <nLen> characters long containing spaces or, if the
             optional <cValue> parameter was used, the same string either
             truncated or padded with spaces to make it <nLen> characters
             long.  If no parameters are passed, a string of 10 spaces is
             returned.

  Description:  This function is primarily intended for use in creating
                a template for multi-key, free-format index files.

                You can also use this function as a generic formatter for
                character strings.  In other words, if you want to make
                sure that a character variable is a specific length, you
                can pass the desired length as the first parameter, and
                the character variable as the second parameter.  The return
                value will be the same character string set to the desired
                length.  For example:

                  ? sxChar( 6, "Hello" )    // Returns the string "Hello "
                  ? sxChar( 6, 1234567 )    // Returns the string "123456"
                  ? sxChar( 6, "Testing" )  // Returns the string "Testin"

                The example below shows both uses of the sxChar() function.


  NOTE: Just by using this function in your INDEX command, you will create
        an empty Multi-Keyed, Free-Format RYO index.  The INDEX command's
        EMPTY clause is not needed and will have no effect if used.


  Example:

   // In the following example, assume that the first record in the TEST.DBF
   // has "Wayne" in the FIRST field and "Campbell" in the LAST field.

   #include "SIXCDX.CH"

   // Use database and create template index

   USE test VIA "SIXCDX"                       // Open TEST.DBF
   INDEX ON sxChar(10) TAG names               // Create "NAMES" Tag
   SET ORDER TO 0                              // Deselects Index TAG

   // Add two index keys for the same record

   GO TOP                                      // Make sure we're at the top
   Sx_KeyAdd( "NAMES", 1, sxChar( 10, FIRST )) // Adds a key for this rec
   Sx_KeyAdd( "NAMES", 1, sxChar( 10, LAST ))  // Adds second key for same rec

   // Now I can do a seek for this record based on the FIRST or LAST names

   SET TAG TO names          // Select the NAMES tag
   ? dbSeek( "Wayne" )       // TRUE
   ? RecNo()                 // Returns record number 1
   ? dbSeek( "Campbell" )    // TRUE
   ? RecNo()                 // Also returns record number 1.  It worked!



See Also: Sx_KeyAdd() sxNum() sxDate() sxLog() Multi-Key, Free-Format Indexes

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