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

  Syntax:   Sx_TableType()

  Returns:  Numeric value indicating the type of the table.  Currently,
            the following types are supported:

                0 - No Table Open
                1 - Standard .DBF File
                2 - Encrypted .DBF File

  Description:  This function allows you to determine the type of an open
                table.  In this case, the word "type" means the condition
                of the table as far as special options are concerned.  At
                the present time, this function is used primarily as a means
                to detect if the table had been previously encypted.

  Example:

    #include "SIXCDX.CH"

    LOCAL nType := 0

    CLS
    USE test VIA "SIXCDX"

    ? "Table Type: "
    nType := Sx_TableType()
    DO CASE
      CASE nType == 0
        ?? "No Database In Use!"
      CASE nType == 1
        ?? "Standard .DBF"          // This CASE should be evaluated
      CASE nType == 2
        ?? "Encrypted .DBF"
    ENDCASE

    Sx_SetPass("foobar")
    ? "Encrypting TEST.DBF: "
    ?? iif( Sx_DBFencrypt(), "OK", "ERROR" )

    ? "Table Type: "
    nType := Sx_TableType()
    DO CASE
      CASE nType == 0
        ?? "No Database In Use!"
      CASE nType == 1
        ?? "Standard .DBF"
      CASE nType == 2               // This CASE should be evaluated
        ?? "Encrypted .DBF"
    ENDCASE
    CLOSE ALL

    // Now we'll reopen the encrypted table and use the trigger system to
    // prompt the user for the password ("foobar") ...

    USE test VIA "SIXCDX" TRIGGER "MyTrigger"
    Browse()

    //------------------------------//
    FUNC MyTrigger( nEvent, nArea, nFieldPos, xTrigVal )

    LOCAL cPassWord := Space(8)
    LOCAL GetList := {}

      DO CASE

        CASE nEvent == EVENT_POSTUSE
          IF Sx_TableType( xTrigVal ) == 2             // Is table encrypted
            @24,0 SAY "Enter Password:" GET cPassWord  // If so, get password
            READ
            Sx_SetPass( AllTrim( cPassWord ))              // And activate it
          ENDIF

      ENDCASE

    Return( .T. )


    NOTE:  Make sure to trim all trailing spaces from the password before
           passing it on to the Sx_SetPass() function, unless the spaces
           are intended to be part of the password.



See Also: Sx_DBFencrypt() Sx_DBFdecrypt() Sx_IDtype()

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