SET AUTOSHARE

SET AUTOSHARE

Defines network detection for shared file access.

Syntax

      SET AUTOSHARE TO [<nMode>]

Arguments

<nMode> A numeric value 0, 1 or 2 can be specified for <nMode>. The default is 0. If omitted, the network detection mode is switched off.

Description

SET AUTOSHARE is a compatibility command useful for changing a multi-user application to a stand-alone application by changing one line of code in the start routine of a program.

This requires changing only the value of <nMode>:

                    Values for SHARE mode detection
         ---------------------------------------------------------
         Value   Description
         -----   -------------------------------------------------
           0     Disables SHARE mode detection ( default )
           1     Opens database SHARED in a network, and EXCLUSIVE
                 if no network is detected
           2     Always opens databases EXCLUSIVE

To take advantage of SET AUTOSHARE, an application must be programmed for multi-user access, respecting the rules for network programming. For example, record locks must be obtained with RLock() before changing field variables. This way, a multi-user application is created.

To change this application to a single user version, SET AUTOSHARE TO 2 is coded in the start routine.

A developer can SET AUTOMODE TO 1 on the development machine. In this case, performance advantages from EXCLUSIVE file access are available during the development cycle, while SHARED file access is granted in a multi-user environment.

Seealso

Set(), SET AUTOPEN, SET AUTORDER, USE

SET AUTOPEN

SET AUTOPEN

Toggles automatic opening of a structural index file

Syntax

      SET AUTOPEN ON | off | (<lOnOff>)

Arguments

ON | off | (<lOnOff>) The option toggles if a structural index file is automatically opened with the USE command. With ON or .T. (true), an index file is automatically opened. OFF or .F. (false) switch this mode off.

Description

Some replaceable database drivers support automatic opening of index files with the USE command when the index file has the same file name as the database file (without extension). An example is the DBFCDX driver. SET AUTOPEN toggles this behavior.

When SET AUTOPEN is set to ON, which is the default, the USE command automatically opens an index file having the same name as the database file and the file extension returned from OrdBagExt().

Note

If an index file is automatically opened, a controlling index is not activated. The default index order is zero, i.e. records are accessible in physical order in the work area. To select a controlling index, call OrdSetFocus() or use SET AUTORDER for a default controlling index

Example

      // The example demonstrates the effect of SET AUTOPEN with the
      // DBFCDX driver.

      REQUEST DBFCDX

      PROCEDURE Main

         RddSetDefault( "DBFCDX" )
         SET AUTOPEN OFF

         USE Customer
         INDEX ON CustID                    TAG ID   TO Customer
         INDEX ON Upper(LastName+FirstName) TAG Name TO Customer

          USE Customer
          ? OrdCount(), OrdKey()        // result: 0  ""

          SET AUTOPEN ON

          USE Customer
          ? OrdCount(), OrdKey()        // result: 2  ""

          SET AUTORDER TO 1

          USE Customer
          ? OrdCount(), OrdKey()        // result: 2  CUSTID
          ? Ordkey( 2 )                 // result: Upper(LastName+FirstName)

          USE
       RETURN

Seealso

OrdListAdd(), OrdSetFocus(), Set(), SET AUTORDER, SET AUTOSHARE, USE