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>sxnum():</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  sxNum():

  Syntax:     sxNum( [<xValue>] )

  Returns:    If no parameters are passed, the return value is 0.  Otherwise,
              sxNum() attempts to convert any non-numeric parameter to a
              numeric one.

  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 conversion
                functions for insuring that a numeric value is returned.
                For example:

                  ? sxNum( 12345 )     // Returns 12345 as a numeric
                  ? sxNum( "12345" )   // Returns 12345 as a numeric


  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:

    // Assume that I want, for whatever reason, to actually store the
    // data for a customer number in the CDX file itself.  Get it?  The
    // data is not even going to be contained in the DBF file at all!

    #include "SIXCDX.CH"

    SET DECIMALS TO 0
    USE test VIA "SIXCDX" EXCL             // Open CUSTOMER.DBF

    test->FIRST := "Ben"                   // Make sure Mr. Ben Dover
    test->LAST  := "Dover"                 //  is in the database

    INDEX ON sxNum() TAG custno            // Create "CUSTNO" Tag
    INDEX ON last TO last                  // Create LAST.IDX.  This will
                                           //  push TEST.CDX into order 2

    // Add a customer number (12345) to the index for Ben Dover's record

    IF dbSeek( "Dover" )                   // Look for Mr. Dover
      Sx_KeyAdd( 1, 2, sxNum( 12345 ))     // Adds a key for this record
    ELSE
      Alert( "Not Found!" )
      QUIT
    ENDIF

    // Now, to prove that we've store some data for this record in the index
    // file, let's retrieve the data with the Sx_KeyData() function

    SET TAG TO custno
    ? "SEEK 12345....: " + iif( dbSeek( 12345 ), "OK", "FAILED" )

    ? "FIRST.........: " + FIRST                   // Returns "Ben"
    ? "LAST..........: " + LAST                    // Returns "Dover"
    ? "Sx_KeyData()..: " + Str( Sx_KeyData(), 5 )  // Returns 12345



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

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