CT_FILECHECK

 FILECHECK()
 Calculates/computes/determines a checksum for a file

 Syntax

     FILECHECK(<cFile>) --> nCheckSum

 Argument

     <cFile>  Designates which file name (with path, if required), to
     check.

 Returns

     FILECHECK() returns a checksum value for <cFile>.

 Description

     FILECHECK() determines if there have been changes or read errors in a
     file, and then takes note of data backup.  This also allows you to
     protect your hard disk from simple viruses (see Examples).

 Note

     .  You must specify the argument.  If it is omitted or an
        unavailable file is specified, FILECHECK() returns an error code of -
        1.  You may use a drive and access path, but no wildcards.

 Examples

     .  Check database for changes:

        IF FILECHECK("CUST.DBF") <> Old_ChkSum
           ? "Warning! Data back-up required."
        ENDIF

     .  Check COMMAND.COM for changes:

        IF FILECHECK("\COMMAND.COM") <> Cmd_ChkSum
           ? "COMMAND.COM has been changed! Caution, Virus!"
        ENDIF

See Also: DISKCHECK() SETSHARE()

CT_FILECDATI

 FILECDATI()
 Determines whether a source file's date and time stamp or the system's date
 and time stamp, should be used to create or copy a file.  Use original or
 system time for a copy

 Syntax

     FILECDATI([<lNewMode>]) --> lOldMode

 Argument

     <lNewMode>  Designates the new status for FILECDATI().  When .T. is
     designated, the target file contains the source file date; when it is
     .F., the system date.  The default is the source file date (.T.).

 Returns

     If no parameter is designated, FILECDATI() returns the current setting
     for FILECDATI(); otherwise, it returns the previous setting.

 Description

     FILE COPY DATE TIME
     FILECDATI() determines which date the target file contains with a
     FILECOPY().  When you partition to several disks in backup mode, this
     concerns all target files.  The CA-Clipper Tools default is .T., where
     the target file contains the date and time of the source file.  If you
     call FILECDATI() with the parameter designated .F., then the target file
     contains the system date and time.

 Notes

     .  Use this function before FILECOPY().

     .  If the target file contains a unique setting such as a pseudo
        serialization, use the SETFDATI() function.

 Examples

     .  Query the FILECDATI() setting:

        ? FILECDATI()            // The current setting

     .  The target file is to contain the system date and time:

        ? FILECDATI(.F.)         // Returns the previous setting

See Also: FILECOPY() SETFDATI()

CT_FILECCONT

 FILECCONT()
 Copies sections of a file in backup mode
------------------------------------------------------------------------------
 Syntax

     FILECCONT(<cFile>) --> nCopyByte

 Argument

     <cFile>  Designates the file name for the target file.

 Returns

     FILECCONT() returns the number of bytes copied.

 Description

     FILE COPY CONTINUE
     Use this function primarily after a FILECOPY().  As much as possible of
     the remaining data is written to a new disk.  If the remaining data
     still does not fit on the designated target disk, call this function
     repeatedly until it writes all the remaining data.  Each time you call
     FILECCONT(), a new name can be designated for the target file.  These
     files are then numbered consecutively (see Examples).

 Notes

     .  If a copy procedure on multiple disks terminates for any
        reason, call FILECCLOSE().

     .  Use SETFCREATE() to designate an attribute to form a new file.

     .  The function acknowledges the CSETSAFETY() implementation, as
        does FILECOPY()

 Example

     Show a back up with FILECOPY().  After terminating, close the source
     file:

     FILECOPY(cSource, cTarget, .T.)   // Back up mode
     DO NEXTDISK                       // When terminated  Terminated = .T.
     DO WHILE FILECOPEN() .AND. .NOT. Terminated
        FILECCONT(cTarget)             // Next disk, new name
        DO NEXTDISK                    // Request for disk exchange
     ENDDO
     IF Terminated
        FILECCLOSE()                   // Close source file!
     ENDIF

See Also: FILECOPY() FILECOPEN() FILECCLOSE() FILECDATI()

CT_FILECCLOSE

 FILECCLOSE()
 Closes a file after backup mode

 Syntax

     FILECCLOSE() --> lClosed

 Returns

     FILECCLOSE() returns .T., when the the file that was opened with
     FILECOPY() is successfully closed.

 Description

     FILE COPY CLOSE
     After you copy on multiple disks, this function should be routinely
     called.  This is to prevent the source file, previously designed with
     FILECOPY(), from remaining open.  For example, this may occur if you
     terminate the copy procedure.

 Note

     .  Regardless of the share mode, all other users are not allowed
        access. This situation stays this way without needing a file handle.

 Example

     Show a back up with FILECOPY().  After terminating, close the source
     file:

     FILECOPY(cSource, cTarget, .T.)      // Back up mode
     DO NEXTDISK                          // When terminated   Terminated =
     .T.
     DO WHILE FILECOPEN() .AND. .NOT. Terminated
        FILECCONT(cTarget)                // Next disk, new name
        DO NEXTDISK                       // Request for disk exchange
     ENDDO
     IF Terminated
        FILECCLOSE()                      // Close source file!
     ENDIF

See Also: FILECOPY() FILECCONT() FILECOPEN()

CT_FILEATTR

 FILEATTR()
 Determines a file's attributes
------------------------------------------------------------------------------
 Syntax

     FILEATTR([<cFile>]) --> nFileAttr

 Argument

     <cFile>  Designates the file name, including the path and drive
     designation.

 Returns

     FILEATTR() returns the attributes for the researched entry or the
     attribute from the FILESEEK() buffer (when called without a parameter).

 Description

     FILEATTR() is implemented alone or in conjunction with FILESEEK().  If
     the function is called with the <cFile> parameter, it returns the
     attribute of the first entry found.  If no acceptable entry is
     available, a value of 0 is returned.

     When called without a parameter, FILEATTR() returns the attribute for
     the most-recent file located with FILESEEK().  When used with
     FILESEEK(), you can determine the attribute for file groups (wildcards).

     When you call FILEATTR() with the <cFile> parameter, the function
     internally passes 63 (all attributes) as a mask.  When used in
     conjunction with FILESEEK(), you should also designate all 63 as an
     attribute mask, if all files are to be acknowledged.

     Table 7-11:  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)
     8       FA_VOLUME           VOLUME (Name of a floppy/hard disk)
     16      FA_DIRECTORY        DIR (Directory)
     32      FA_ARCHIVE          ARCHIVE (Changes since last backup)
     ------------------------------------------------------------------------

     If multiple attributes are implemented for a file, the value of each
     corresponding attribute is added.

 Examples

     .  Show the attribute of a specific file:

        ? FILEATTR("C:\TEXT\TEXT.TXT")      // 32  ARCHIVE

     .  The attribute for an ARCHIVE/HIDDEN file:

        ? FILEATTR("C\HIDE.TXT")            // 34  HIDDEN + ARCHIVE

     .  Used in conjunction with FILESEEK():

        cFile  :=  FILESEEK("C:\TEXT\TEXT.TXT")
        DO WHILE .NOT. EMPTY (cFile)
           ? cFile, FILEATTR()              // Name & file attribute
           cFile  :=  FILESEEK()            // Search for next entry
        ENDDO

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

CT_FILEAPPEND

 FILEAPPEND()
 Appends data to a file

 Syntax

     FILEAPPEND(<cSourceFile>, <cTargetFile>)
        --> nAttachedByte

 Arguments

     <cSourceFile>  Designates the file that is appended to
     <cTargetFile>.

     <cTargetFile>  Designates the file to which <cSource> is appended.
     Drive and path designation are permitted for both files, wildcards are
     not.

 Returns

     FILEAPPEND() returns the number of characters appended on to
     <cTargetFile>.

 Description

     FILEAPPEND() takes fragmented files, split them up on different floppies
     and reassemble them.  This sort of fragmented file could be created with
     the FILECOPY() system described in this chapter.  You only need explicit
     information, such as VOLUME labels, to recognize the different disks.
     If the target file does not exist, it is created with FILEAPPEND().  If
     an error occurs while appending to the target file, the file deletes
     completely to avoid accidental and incorrect results.

     Never append data to file if there is no backup copy.

 Notes

     .  Use SETFCREATE(), if FILEAPPEND() creates a new file and an
        alternative attribute needs to be specified.

     .  Use SETSHARE() to protect a target file from access, if it is
        on a network drive.

 Examples

     Shown below is a simplified program to reassemble a file that is divided
     among several disks by a FILECOPY() backup.

     A catalog contains a list of the disks used during backup in the form of
     volume labels and backup file names.

     Structure of the DISKLIST catalog:

     Table 7-10: DISKLIST File Structure
     ------------------------------------------------------------------------
     Field Name     Field Content
     ------------------------------------------------------------------------
     VolLabel       Back up disk drive and volume label
     BackupName     Back up file name, incl. drive and path
     ------------------------------------------------------------------------

     The data in DISKLIST is created by a FILECOPY() backup:

     USE DISKLIST                                 // Saved volume labels
     cTargetFile  :=  "C:\TARGET.TXT"
     DO WHILE .NOT. EOF()
        IF .NOT. EMPTY(FILESEEK(cVolLabel, 8)     // Correct disk ?
           FILEAPPEND(cBackupName, cTargetFile)   // Yes, append data
           SKIP
        ELSE
           ? "Please insert the correct disk  !"
        ENDIF
     ENDDO

See Also: FILECOPY() FILESEEK() SETSHARE() SETFCREATE() CSETSAFETY()

CT_DRIVETYPE

 DRIVETYPE()
 Determines the drive type

 Syntax

     DRIVETYPE([<cDrive>]) --> nDriveType

 Argument

     <cDrive>   Designates the drive (A, B, C, etc.) for which the type
     is determined.  The default is the current drive.

 Returns

     DRIVETYPE() returns a numeric value for the drive type.  The following
     codes apply:

     Table 7-9:  Drive Type Coding
     ------------------------------------------------------------------------
     Code    Definition
     ------------------------------------------------------------------------
     0       RAM Disk
     1       Floppy Disk (disk change cannot be established by system)
     2       Floppy Disk (disk change can be established by system)
     3       Hard Disk
     ------------------------------------------------------------------------

 Description

     Warning!  Only for AT-class computers.

     This function determines if you are dealing with a floppy drive, a hard
     disk, or a RAM disk.

 Note

     .  Although DRIVETYPE() returns a 0 value for logical DOS
        partitions, RAM floppies, and unavailable drives, you must also
        differentiate with DISKTYPE().  Here, each hard disk partition
        returns a 248 value.  A RAM floppy created with VDISK.SYS behaves
        like a single-sided floppy with eight sectors, which returns a 254
        value.  If there is an unavailable drive, the DISTYPE() returns a
        value of 0.

 Example

     Determine if the drive is a RAM floppy:

     IF DRIVETYPE() == 0 .AND. DISKTYPE() == 254
        ? "Drive " + DISKNAME() + ":  is a RAM-disk!"
     ENDIF

See Also: DISKTYPE() DISKNAME()

CT_DISKTYPE

 DISKTYPE()
 Determines the type of data carrier

 Syntax

     DISKTYPE([<cDrive>]) --> nDiskType

 Argument

     <cDrive>  Designates the drive designator (A, B, C, etc.) for which
     you want to determine the data carrier.  The default is the current
     drive.

 Returns

     The returned value corresponds to the FAT-ID byte of a floppy or hard
     disk.  The following codes apply:

     Table 7-8:  FAT-ID Definitions
     ------------------------------------------------------------------------
     FAT-ID  Symb. constants     Definition
     ------------------------------------------------------------------------
     255     DT_DS_SEC_8         Double sided 8 sectors
     254     DT_SS_SEC_8         Single sided 8 sectors
     253     DT_DS_SEC_9         Double sided 9 sectors
     252     DT_SS_SEC_9         Single sided 9 sectors
     249     DT_DS_SEC_15        Double sided 15 sectors (HD-Disk)
     249     DT_35_SEC_9         Double sided 3.5" 9 sectors (ident. to 5.25"
                                 HD)
     240     DT_35_SEC_18        Double sided 3.5" 18 sectors
     248     DT_HARDDISK         Hard disk
     ------------------------------------------------------------------------

 Description

     If a 360K floppy is written on an AT in a 1.2 MB drive, you may not be
     able to read it on other systems, particularly on PC XTs.  This function
     determines how the floppy you are about to use is formatted and provides
     the corresponding warning.

 Example

     Determine if an XT disk is being written to an AT:

     IF ISAT() .AND. DISKTYPE("A") == DT_DS_SEC_9
        ? "Warning!"
        ? "Under certain circumstances this disk not"
        ?? " readable on other systems!"
     ENDIF

See Also: DISKNAME() DRIVETYPE() FLOPPYTYPE()

CT_DISKTOTAL

 DISKTOTAL()
 Determines the total capacity of a floppy or hard disk

 Syntax

     DISKTOTAL([<cDrive>]) --> nTotalSpace

 Argument

     <cDrive>  Designates the drive for which memory capacity is
     determined.  The default is the current drive.

 Returns

     DISKTOTAL() returns a value that corresponds to the total capacity of
     the data carrier in the selected drive.  The default is the current disk
     drive.

 Description

     DISKTOTAL() determines if the capacity of the disk in use is sufficient
     for back up.  The advantage of DISKTOTAL() over any capacity determined
     by the system, is that it recognizes bad sectors and does not include
     them.

 Example

     Determine if disk capacity is sufficient:

     nRequired  :=  DBFSIZE()
     IF DISKTOTAL("A") < nRequired
        ? "Error! Insufficient disk capacity!"
     ENDIF

See Also: DISKFREE()

 

CT_DISKSTAT

 DISKSTAT()
 Determines the status of a drive.

 Syntax

     DISKSTAT([<cDrive>]) --> nStatus

 Argument

     <cDrive>  Designates the drive designator (A, B, C, etc.) of the
     drive for which the status of the last operation is determined.  The
     default is the current disk drive.

 Returns

     DISKSTAT() returns the status of the floppy or hard disk operation as a
     number.  The bits have the following meanings:

     Table 7-7:  Drive Status Coding
     ------------------------------------------------------------------------
     Bit     Symb. constants     Definition
     ------------------------------------------------------------------------
     1       DST_INVALID         Unknown command
     2       DST_READONLY        Address marker not found
     3       DST_SECTOR          Sector not found
     4       DST_DMA             DMA overflow
     5       DST_CRC             CRC error
     6       DST_CONTROLLER      Controller error
     7       DST_SEEK            Seek operation failure
     8       DST_TIMEOUT         Timeout error
     ------------------------------------------------------------------------

 Description

     When DOS returns a "block device error" message  (See ERRORORG()) and
     DISKSTAT() to determine a more detailed cause of the error).

 Note

     .  This function passes the system status to a CA-Clipper
        application.  The system saves a status value for all floppy and hard
        disk operations.  When you reaccess a floppy disk drive from within
        your program, the previous disk operation status is lost.  The same
        applies to hard disk status.

 Example

     Determine if the system was unable to find an address marker:

     IF ERRORORG() == DST_READONLY
        DiskError  :=  DISKSTAT("A")
     ENDIF

See Also: ERRORBASE() ERRORCODE() ERRORORG()