CT_SETSHARE

 SETSHARE()
 Sets the default opening mode (share mode) for Clipper Tools file
 functions

 Syntax

     SETSHARE(<nShareMode>) --> lAccepted

 Argument

     <nShareMode>  Designates the desired share mode.

 Returns

     SETSHARE() returns .T. when the desired share mode is implemented (must
     be DOS version - 3.1 or higher).

 Description

     The setting you implement here influences all Clipper Tools functions
     that open, read, or write to a file.  The share mode can be set here.
     It determines when a program opens a file under DOS and how other
     programs within a network may address this file.  The Clipper Tools
     default is 0, compatibility mode.  The following codes apply:

     Table 7-23: Share Mode Coding
     ------------------------------------------------------------------------
     Code    Share Mode
     ------------------------------------------------------------------------
     0       Compatibility mode.  Here DOS or the network software itself
             determines the share mode.  In Novell networks, the SHAREABLE
             attribute plays an important role in this relationship.
     1       Both read and write by other programs are locked out.
     2       Write by other programs are locked out.
     3       Read by other programs are locked out.
     4       Not locked.  Read and write by other programs is allowed
     ------------------------------------------------------------------------

 Note

     Important!  This function can only be used with DOS versions 3.1 or
     higher.  Older versions return .F..

 Examples

     .  Change share mode, prohibit writing by others:

        ? SETSHARE(2)          // .T., when >= DOS 3.1

     .  Bad parameter:

        ? SETSHARE(12)         // .F.

See Also: GETSHARE()

 

CT_SETFDATI

 SETFDATI()
 Sets the date and time of a file

 Syntax

     SETFDATI(<cFile>, [<dFileDate>], [<cFileTime>]) --> lAmended

 Arguments

     <cFile>  Designates for which file the date and/or time is changed.
     Drive and path designations are possible, wildcards are not.

     <dFileDate>  Designates the date for the file.  The default is the
     system date.

     <cFileTime>  Designates the time for the file.  The default is the
     system time.

 Returns

     SETFDATI() returns .T. when the change is successfully executed.

 Description

     SETFDATI() permits you to set the clock date and time of a file.  Since
     the date and time of a file usually change at the same time, these have
     been brought together in one function.  It is possible to only change
     the time or the date, when one parameter is given and the other is not.
     The different parameter types tell the function what is to change.

 Note

     .  The time is given in a 24-hour format, that is between
        "00:00:00" and "23:59:59".

 Examples

     .  Set the date and time:

        SETFDATI("C:\TEXT\TEST.TXT", CTOD("01/01/91"), "01:10:00")

     .  Set current date and time:

        SETFDATI("TEST.TXT")                  // DATE() + TIME()

     .  Only change the date:

        SETFDATI("TEST.TXT", DATE() -10)      // Ten days prior to today

     .  Only change the time, resetting to start time:

        SETFDATI("TEST.TXT", SECTOTIME(Start))

See Also: FILESEEK() FILEDATE() FILETIME() SECTOTIME()

 

CT_SETFCREATE

 SETFCREATE()
 Default attribute for creating with Clipper Tools functions

 Syntax

     SETFCREATE([<nNewFileAttr>]) --> nOldFileAttr

 Argument

     <nNewFileAttr>  Designates a file attribute for a new file.

 Returns

     SETFCREATE() returns the current default attribute or the previous file
     attribute, if the parameter is specified.

 Description

     Clipper Tools functions use a value of 32 (setting the ARCHIVE bit)
     to preset the default for file creation.  For example, use SETFCREATE()
     when a file needs to acquire another attribute in a network environment.

     Table 7-22:  Coding the File Attribute
     ------------------------------------------------------------------------
     Value   Symb. constants     Assigned attribute
     ------------------------------------------------------------------------
     0       FA_NORMAL
     1       FA_READONLY         READ ONLY (Read-only)
     2       FA_HIDDEN           HIDDEN (Hidden files)
     4       FA_SYSTEM           SYSTEM (System files)
     32      FA_ARCHIVE          ARCHIVE (Changes since last backup)
     ------------------------------------------------------------------------

 Note

     .  The set values only apply to files you create with Clipper
        Tools functions.

 Examples

     .  Create a read-only file:

        SETFCREATE(1)
        STRFILE("Nantucket", "TEST.TXT")

     .  Query the attribute set:

        ? SETFCREATE()

See Also: STRFILE() FILECOPY() FILECCONT() FILEAPPEND()

 

CT_SETFATTR

 SETFATTR()
 Sets a file's attributes

 Syntax

     SETFATTR(<cFile>, <nFileAttr>) --> nErrorCode

 Arguments

     <cFile>  Designates the file that has attributes you want to change.
     Drive and path designations are allowed, but no wildcards.

     <nFileAttr>  Designates the new attributes in numeric form.  The
     default is 32 (ARCHIVE).

 Returns

     SETFATTR() returns the attribute implemented to the designated file or a
     negative value as an error code.  The codes are explained below:

     Table 7-20:  SETFATTR() Error Codes
     ------------------------------------------------------------------------
     Code    Symb. constants     Definition
     ------------------------------------------------------------------------
      0      NO_DISK_ERR         No error found
     -2      ER_FILE_NOT_FOUND   File not found
     -3      ER_PATH_NOT_FOUND   Path not found
     -5      ER_ACCESS_DENIED    Access denied (e.g., in network)
     ------------------------------------------------------------------------

 Description

     This function permits you to change a file attribute.  The attributes
     are represented as a numeric value and explained in the table below:

     Table 7-21:  Coding the File Attribute
     ------------------------------------------------------------------------
     Value   Symb. constants     Assigned attribute
     ------------------------------------------------------------------------
     0       FA_NORMAL
     1       FA_READONLY         READ ONLY (Read-only)
     2       FA_HIDDEN           HIDDEN (Hidden files)
     4       FA_SYSTEM           SYSTEM (System files)
     32      FA_ARCHIVE          ARCHIVE (Changes since last backup)
     ------------------------------------------------------------------------

     If you implement multiple attributes for a file, you must also add the
     individual values.

 Notes

     .  Use the VOLUME() function to create volume labels and
        directories through the DIRMAKE() function.  Additional attributes
        can also be set at directory level.

     .  The BITTOC() and CTOBIT() functions can prove helpful in
        conjunction with the file attributes.

     .  An attempt to set (.AND...) attributes at pseudo files can
        trigger a system crash.

 Examples

     .  Set a file to HIDDEN:

        ? SETFATTR("TEST.TXT", 2)       // Returns 0, if successful

     .  When a file is not available:

        ? SETFATTR("ABCDEFGH"), 2)      // Returns: -2

     .  Influence the return value:

        nAttribute  := SETFATTR("TEST.TXT", 7)
        IF nAttribute <> 7
           *...
        ENDIF

See Also: FILESEEK() FILEATTR() BITTOC() CTOBIT()

 

CT_SAVEFSEEK

 SAVEFSEEK()
 Saves the current FILESEEK environment

 Syntax

     SAVEFSEEK() --> cFileSeekEnvironment

 Returns

     SAVESEEK() returns the current FILESEEK() environment.  The information
     is needed for RESTFSEEK().

 Description

     The function saves the current FILESEEK() environment to a string.  For
     example, if the sequence "First Search - Continued Search" is
     interrupted by branching into a subdirectory, you must save these files.

 Note

     .  Be sure sufficient spare memory is available when working
        recursively at a higher level of complexity (which depends on the
        number of subdirectories).  See Examples on the following page.

 Example

     The following small program shows all the files in all directories of
     the current drive, from the root.  The GetFiles procedure can be called
     recursively:

     DO GetFiles WITH "\"              // Starts with root directory
     RETURN
     * ----------------------------------------
     PROCEDURE GetFiles(cSearchPath)
     PRIVATE cSeekEnv                  // Picks up SEEK environment
     ?                                 // Empty line for new dir.
     * All files, all attributes
     cFile  := FILESEEK(cSearchPath + "*.*", 63)
     DO WHILE .NOT. EMPTY(cFile)
        IF cFile <> "."                // ".." and "." are dummys
           IF ISBIT(FILEATTR(), 5)     // Subdirectory?
           cSeekEnv := SAVEFSEEK()     // Save environment
           * Recursive call with extended path!
           DO GetFiles WITH cSearchPath + cFile + "\"
           RESTFSEEK(cSeekEnv)         // Restore environment
           ELSE
           ? cSearchPath + cFile
           ENDIF
        ENDIF
        cFile := FILESEEK()            // Next file
     ENDDO
     RETURN

See Also: RESTFSEEK()

CT_RESTFSEEK

 RESTFSEEK()
 Restores the FILESEEK environment

 Syntax

     RESTFSEEK(<cFileSeekEnvironment>) --> cNull

 Argument

     <cFileSeekEnvironment>  Designates a string that contains the
     FILESEEK() environment, which was passed by SAVEFSEEK().

 Returns

     RESTFSEEK() always returns a null string.

 Description

     RESTFSEEK() restores a saved FILESEEK() environment.  Use both of these
     functions to run through subdirectories recursively.

 Example

     The following small program shows all the files in all directories of
     the current drive, from the root.  The GETFILES procedure can be called
     recursively:

     DO GetFiles WITH "\"                  // Starts with root directory
     RETURN

     * ----------------------------------------
     PROCEDURE GetFiles(cSearchPath)
     PRIVATE cSeekEnv                      // Picks up SEEK environment
        ?                                  // Empty line for new dir.
     * All files, all attributes
     cFile  := FILESEEK(cSearchPath + "*.*", 63)

     DO WHILE .NOT. EMPTY(cFile)

        IF cFile <> "."                    // ".." and "." are dummys
           IF ISBIT(FILEATTR(), 5)         // Subdirectory?
              cSeekEnv := SAVEFSEEK()      // Save environment
              * Recursive call with extended path!
              DO GetFiles WITH cSearchPath + cFile + "\"
              RESTFSEEK(cSeekEnv)          // Restore environment
           ELSE
              ? cSearchPath + cFile
           ENDIF
        ENDIF
        cFile := FILESEEK()                // Next file
     ENDDO

     RETURN

See Also: FILESEEK() SAVEFSEEK()

 

CT_RENAMEFILE

 RENAMEFILE()
 Fault tolerant renaming of a file.

 Syntax

     RENAMEFILE(<cOldFileName>, <cNewFileName>) --> nErrorCode

 Arguments

     <cOldFileName>   Designates the name and path of the existing file.

     <cNewFileName>   Designates the new name and path for the file.

 Returns

     The function returns a 0 when the file can be renamed; otherwise, it
     returns an error code.  The codes are defined below:

     Table 7-19:  RENAMEFILE() Error Codes
     ------------------------------------------------------------------------
     Code    Definition
     ------------------------------------------------------------------------
      0      No error found
     -2      File not found
     -3      Path not found
     -5      Access denied (e.g., in network)
     -17     Target file not on same network
     ------------------------------------------------------------------------

 Description

     Currently, you may not be able to rename a file on a network drive.
     Another user may currently have the file open.  RENAMEFILE() actually
     says "attempt a RENAME and, should the situation arise, return an error
     code".  This follows the basic programming philosophy:  never fall into
     an error trap when you can avoid it.

 Notes

     .  The <cNewFileName> must always contain the complete path for
        the designated file (see Examples).

     .  Wildcard characters cannot be used.

 Examples

     .  Rename a file from OLD to NEW:

        IF RENAMEFILE("OLD", "NEW") = 0
           ? "The file is renamed!"
        ENDIF

     .  Use the path from the old file specification for the new name:

        cFSpecOld   := "C:\TEST\TEST.TXT"
        cFileName   := TOKEN(cFSpecOld, ":\")      // last token
        cFSpecNew   := BEFOREATNUM(cFileName, cFSpecOld) + "TEST.NEW"
        RENAMEFILE(cFSpecOld, cFSpecNew)

See Also: DELETEFILE()

CT_NUMDISKL

 NUMDISKL()
 Determines the number of available logical drives

 Syntax

     NUMDISKL() --> nNumber

 Returns

     The returned value gives the number of logical drives used by DOS.

 Description

     NUMDISKL() returns the number of available drives or the value specified
     by LASTDRIVE = in CONFIG.SYS.  In a NOVELL network, you can determine
     which is the first network drive (LASTDRIVE +1).

 Note

     .  Normally, the function return value is 5, if there is no
        deviating input in CONFIG.SYS for LASTDRIVE =.

 Example

     Display which drive is the first network drive:

     ? "First Network Drive:  " + CHR(NUMDISKL() + 65) + ":"

See Also: NUMDISKF() NUMDISKH()

 

CT_NUMDISKH

 NUMDISKH()
 Determines the number of hard disks

 Syntax

     NUMDISKH() --> nNumber

 Returns

     NUMDISKH() returns the number of physical hard disk drives.

 Description

     This function determines the number of physical hard disk drives (one or
     two).  These should not be confused with logical hard disk drives, that
     can be designated with DOS 3.3.

 Note

     .  The function receives its information from the BIOS.

 Example

     .  How many hard disk drives does my system have?

        ? NUMDISKH()         // Result:  1

See Also: NUMDISKF() NUMDISKL()

 

CT_NUMDISKF

 NUMDISKF()
 Determines the number of installed disk drives

 Syntax

     NUMDISKF() --> nTotalFloppy

 Returns

     NUMDISKF() returns a value that specifies how many disk drives are
     installed in the system.

 Description

     NUMDISKF() determines the number of disk drives and allows you to choose
     which drive you want to copy onto.

 Example

     Determine if a B: drive exists:

     IF NUMDISKF() == 2
        IF DISKREADY("B")
           ? "You can also use Drive B:!"
        ENDIF
     ENDIF

See Also: NUMDISKL() NUMDISKH()