CT_DISKSPEED

 DISKSPEED()
 Determines a comparison value for the drive speed

 Syntax

     DISKSPEED(<cDrive>) --> nDriveSpeed

 Argument

     <cDrive>  Designates for which physical drive identifier (A, B, C,
     etc.) to determine the speed.  You do not need to use the colon (:).

 Returns

     DISKSPEED() returns a percentage comparison value to a floppy drive of a
     4.77 MHz PC, which corresponds to 100%.

 Description

     Use this function when you want to calculate the approximate duration of
     such complex file operations as INDEX or SORT.  Since the total duration
     always depends upon the remaining computer speed, you should also use
     the SPEED() function..

     If the designated drive is unavailable or cannot be checked (network
     drive), the function returns a 0 value.

 Note

     .  You can only implement DISKSPEED() for physical drives, not
        network drives.

 Examples

     .  Show the speed of drive A:

        ? DISKSPEED("A")            // depends on drive

     .  Show the factor for your hard disk:

        ? DISKSPEED("C")            // e.g. 720  Factor 7.2

See Also: SPEED()

CT_DISKREADYW

 DISKREADYW()
 Queries whether you can write to a drive
------------------------------------------------------------------------------
 Syntax

     DISKREADYW([<cDriveId>]), [<lDOS/BIOS>]) --> lDiskReady

 Arguments

     <cDriveId>  Designates which drive designator (A, B, C, etc.) to
     query.  The default value is the current disk drive.

     <lDOS/BIOS>  This logical parameter allows you to specify whether
     you want to query the function through the BIOS (.F.) or DOS (.T.).  The
     default is described in the Description below.

 Returns

     DISKREADYW() returns .T. when you query a drive that is operational and
     can be written to.

 Description

     As with DISKREADY(), this function determines if a drive is ready to
     use.  DISKREADYW() also determines if you can write to a drive.
     DISKREADY() cannot tell if a disk has a write-protect marker on it.  In
     this case, drive A: might be ready, but you could not write to it.  Use
     this function to build write-protect detection for important disks into
     the program.

 Network Drives 

     In general, drives mapped within networks are viewed by the function as
     accessible and return .T. as a result.  For a disk, "accessible" means
     you can create, open, and delete files.  You can clearly differentiate
     these rights within networks such as Novell NETWARE.  Therefore, you
     must test for these accordingly.

 DOS or BIOS 

     In the simplest case, this function always tests the respective drive
     through DOS.  If drive B: is unavailable, the message  "Please insert
     disk in drive B:" is output from the operating system.  When you test
     floppy drives drive A: and B:, the BIOS route is recommended, since no
     message is output.  In any event, A: and/or B: can be mapped drives
     within a network.  Use the following logical expression to cover all the
     previous situations:

     (NETDISK(<cDrive>) .OR. <cDrive> >= "C")

     This logical expression returns .T. when the respective drive is either
     on the network or has a drive identifier of C: or higher.

 Note

     .  Research indicates work in the OS/2 compatibility box must be
        in the BIOS mode.

 Example

     Determine if you can write a file to A: drive:

     IF DISKREADY("A")
        IF NETDISK ("A")
           IF NNETRIGHTS ("A:\")      // complete path
           * ...
           ENDIF
        ELSE
           IF DISKREADYW("A")
           ? "Disk is not write protected!"
           ELSE
           ? "Disk is write protected!"
           ENDIF
        ENDIF
     ELSE
        ? "Disk drive not ready!"
     ENDIF

See Also: DISKREADY()

CT_DISKREADY

 DISKREADY()
 Tests to see if a disk drive is ready

 Syntax

     DISKREADY([<cDrive>], [<lDOS/BIOS>]) --> lDiskReady

 Arguments

     <cDrive>  Designates the drive designator (A, B, C, etc.) of the
     drive to test.  The default is the current disk drive.

     <lDOS/BIOS>  This logical parameter allows you to designate whether
     you want the function tested through the BIOS (.F.) or DOS (.T.).  The
     default is discussed in the Description below.

 Returns

     DISKREADY() returns .T. when the drive being tested is ready to use.

 Description

     To save space, you must frequently make multiple disk copies.
     DISKREADY() allows you to wait for a user disk change, without having to
     confront known DOS errors, or use CA-Clipper error trap functions.  Be
     sure to differentiate between floppy tests and "true" hard disks and
     logical partitions.

 DOS or BIOS

     In the simplest case, this function tests the respective drive through
     DOS.  If drive B is unavailable, the message  "Please insert disk in
     drive B:..." is output from the operating system.  When you test floppy
     drives, drive A: and B:, the BIOS route is recommended, since no message
     is output.  In any event, A: and/or B: can be mapped drives within a
     network.  Use the following logical expression for all the previous
     situations:

     (NETDISK(<cDrive>) .OR. <cDrive> >= "C")

     This logical expression returns .T. when the respective drive is either
     on the network or has a drive identifier of C: or higher.

 Examples

     The system waits between individual copy procedures until drive A: is
     ready again:

     DO Copy                        // Call copy procedure
     ? "Please insert a disk in Drive A:!"
     DO WHILE .NOT. DISKREADY("A")
        *...
     ENDDO
     DO Copy                        // Call copy procedure

See Also: DISKREADYW()

CT_DISKNAME

 DISKNAME()
 Determines the drive designator for the current drive

 Syntax

     DISKNAME() --> cDrive

 Returns

     DISKNAME() returns a letter that identifies the designator as the
     current drive.

 Description

     DISKNAME() determines the current drive designator for the construction
     of complete path names.

 Note

     .  The designator does not contain a colon.

 Example

     Display the drive designator for the current drive:

     ? DISKNAME()      // Returns a "C" with most hard disk systems

See Also: DIRNAME()

CT_DISKFREE

 DISKFREE()
 Determines the space available on a floppy or hard disk
------------------------------------------------------------------------------
 Syntax

     DISKFREE([<cDrive>]) --> nFreeByte

 Argument

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

 Returns

     DISKFREE() returns the available memory capacity of the selected drive.

 Description

     DISKFREE() determines if a disk has sufficient storage capacity for a
     file.

 Note

     .  When <cDrive> is not specified, the function automatically
        uses the current drive.

 Example

     Determine if there is enough space to copy a database:

     Required  :=  DBFSIZE()         // Database size
     IF DISKFREE("A") < Required
        ? "Insufficient disk space for copying!"
     ENDIF


See Also: DISKTOTAL()

CT_DISKFORMAT

 DISKFORMAT()
 Formats disks, controlled through a UDF
------------------------------------------------------------------------------
 Syntax

     DISKFORMAT(<cDrive>, [<nCapacity>], [<cUDF>],
        [<cBootText>], [<nRepetitions>]) --> nErrorCode

 Arguments

     <cDrive>  Designates the disk drive to format.  Only a floppy drive
     is permitted.  You may optionally specify a colon (:).

     <nCapacity>  Designates the appropriate disk capacity for the disk
     you are about to format.  Possible values are 160, 180, 320, 360, and
     1200 for 5.25"; 720 and 1440 for 3.5" disks.  The default is the maximum
     drive capacity.

     <cUDF>  Designates the name of a user-defined function call before
     each format step (track or head change).  The default is no UDF called.

     <cBootText>  This optional parameter designates text, with a maximum
     of 255 characters, to display if the formatted disk is booted.  The
     default is described in the "Notes" section on the following page.

     <nRepetitions>  Designates the number of repeat attempts you should
     make, to format a track before the function aborts.  The default is one
     repetition.

 Returns

     The function returns 0 when the disk is successfully formatted.

     Table 7-5:  DISKFORMAT() Error Codes
     ------------------------------------------------------------------------
     Error Codes  Symb. constants     Definition
     ------------------------------------------------------------------------
      0           NO_DISK_ERROR       Format successful
     -1           DF_WRONG_DRIVE      Illegal drive, only A: and B:  allowed
     -2           DF_WRONG_DISK_SIZ   kB value not supported
     -3           DF_INTERRUPTED      Terminated by control UDF
     -4           DF_WRITE            Write error
     ------------------------------------------------------------------------

 Description

     DISKFORMAT() formats a disk under full CA-Clipper program control, so
     there is no need for a RUN FORMAT.  You cannot create bootable disks,
     only data disks.

     Since you can call a separate function (UDF) prior to every track and
     head change and the respective track and head number are passed, you can
     construct the visual display of the format process constructed as
     desired.

     You can only format floppy disks, so even with unforeseen incorrect
     parameters, your hard disk is safe.  All the standard floppy types are
     supported -- 160kB, 180kB, 320kB, 360kB, 1.2MB, 720kB, and 1.44MB.

     DISKFORMAT() is useful for formatting disks, at least when the preset
     repetition rate is retained or decreased.  After an unsuccessful attempt
     to format a track, the process is repeated one more time.  If this
     repetition also fails, the entire format is aborted.  If you want to be
     as safe as possible about the quality of the disk in used, select a
     repetition rate of 0.

 The Control UDF

     DISKFORMAT() calls the control UDF, which is specified as the third
     parameter, prior to each head and track change.  Both values, head and
     track, are passed as a parameter to the function.  As soon as all tracks
     are formatted and DISKFORMAT() has initialized the FAT and directory
     area, a value of -1 is passed for both parameters to the UDF.  Please be
     aware that both parameters must be passed.

     The numeric value returned for UDF can further influence DISKFORMAT():

     Table 7-6:  Control UDF Returned Values
     ------------------------------------------------------------------------
     Returned Value    Explanation
     ------------------------------------------------------------------------
     0                 Continue format
     1                 Do not format this track (parameter 1)
     2                 Abort format
     ------------------------------------------------------------------------

 Notes

     .  If the defined control UDF does not exist, the function
        uninstalls itself and triggers a runtime error.  If an error message
        concerning a missing procedure is required during linking, you can
        specify EXTERNAL <function> in the program.

     .  If you attempt to boot with a data disk created with
        DISKFORMAT() and did not designate any other text for the <cBootText>
        parameter, the following text is displayed:

         "No system disk.  Insert new disk, press any key to continue"

     .  DISKFORMAT() begins to format a disk with the highest track
        number.  Therefore, an existing FAT and directory label are the last
        items deleted.

     .  DISKFORMAT() always reformats a track, even if it is already
        formatted.  Therefore, when a format is successful, all the data is
        deleted.

     .  Each track is verified again after it is formatted.

     .  After the last track is formatted, the function continues to
        work a few seconds more.  The FAT and directory must be established
        and the boot text must be written.

 Examples

     .  An example for formatting a disk in A: drive:

        DISKFORMAT() first determines whether the desired capacity is
        appropriate for the drive.  The control UDF "CONTROL" is concerned
        with the display of the track and head that are currently being
        formatted.  "This is a data diskette" is used as boot text for the
        disk.  The repeat rate is highly effective at 0.  Only the highest-
        quality disks are accepted.

        To provide an additional example of the return value for the UDF,
        only tracks 80 to 11 are formatted here, not the first 10:

        CLEAR
        cBootText  :=  "This is a data diskette"
        @ 10, 02 SAY "Track:
        "@ 11, 02 SAY "Head:
        "IF FLOPPYTYPE("A:") = 2
                                      // 1.2 MB disk
           nErrCode := DISKFORMAT("A:", 1200", CONTROL", cBootText, 0)
           IF nErrCode = 0
              ? "Format successful!"
           ENDIF
        ENDIF
        RETURN

        FUNCTION CONTROL(nTrack, nHead)
           LOCAL nRetval
           IF Track >= 11
              @ 10, 08 SAY STR(nTrack)
              @ 11, 08 SAY STR(nHead)
              nRetval := 0            // Continue format
           ELSE
              nRetval := 2            // Abort
           ENDIF
           RETURN(nRetval)

     .  Shown below is another variation of the UDF.  Press the ESC
        key to abort the format.  If the format is completed, then the
        function displays the FAT initialization and root directory:

        FUNCTION CONTROL(nTrack, nHead)
           LOCAL nRetval
           IF INKEY() = 27
              nRetval := 2            // Abort
           ELSE
              nRetval := 0            // Continue format
           ENDIF
           IF nTrack = -1
              @ 10, 10 SAY "Initializing FAT and Root Directory!"
           ENDIF
           RETURN(nRetval)

See Also: DRIVETYPE() FLOPPYTYPE()

CT_DISKCHECK

 DISKCHECK()
 Creates a checksum for a disk

 Syntax

     DISKCHECK(<cDrive>, [<nStartSector>]) --> nCheckSum

 Arguments

     <cDrive>   Designates which drive (A, B, C, etc.) you want to check.

     <nStartSector>  Designates a sector to serve as a starting point to
     check the disk in the direction of the first sector.

 Returns

     DISKCHECK() returns a number that corresponds to a checksum for the data
     carrier in <cDrive>.  If read errors occur, the function returns a
     negative number when the first bad sector is found.

 Description

     DISKCKECK() begins its check with the last sector of the designated
     drive or with the <nStartSector> value, and works in the direction of
     the first sector.  If a sector is found to contain errors, then it
     returns a negative value.

     If it returns a -1, continue to check for other errors (such as a
     missing disk).  The CA-Clipper Tools function ERRORCODE() is quite
     useful here.  Error code returns a value that symbolizes the most-recent
     DOS error.

     Since DISKCHECK() returns a checksum, it is easy to check for disk
     changes.

 Note

     .  You must specify the <cDrive> parameter.  If you omit it or
        specify an unavailable drive, DISKCHECK() returns an error code of -
        1.  DISKCHECK() takes more time to check a hard disk.

 Examples

     .  Create a checksum for a floppy:

        Checksum  :=  DISKCHECK("A")

     .  Show that the disks are changed:

        IF DISKCHECK("A") == Checksum
           ? "You have not changed disks!"
        ENDIF

See Also: FILECHECK() ERRORCODE()

 

CT_DISKCHANGE

 DISKCHANGE()
 Changes the current disk drive

 Syntax

     DISKCHANGE(<cDrive>) --> lChanged

 Argument

     <cDrive>  Designates which disk drive that you want to use.

 Returns

     DISKCHANGE() returns .T., when the designated disk drive is successfully
     changed.

 Description

     DISKCHANGE() allows you to change from the current disk drive to
     another.  To do this, call DISKCHANGE() with the disk drive identifier
     (A,B,C, etc.).  The drive identifier can be specified with a colon (:).

 Example

     Change to drive C:

     ? DISKCHANGE("C")         // Returns .T. when successful

See Also: DISKNAME() DIRCHANGE()

 

CT_DIRREMOVE

DIRREMOVE()

 Removes a directory
------------------------------------------------------------------------------
 Syntax

     DIRREMOVE(<cDirectory>) --> nErrorCode

 Argument

     <cDirectory>  Designates which directory name to remove.

 Returns

     DIRREMOVE() returns a 0 when the designated directory is successfully
     removed; otherwise, an error code is returned.  The codes are defined as
     follows:

     Table 7-4:  DIRREMOVE() Error Code
     ------------------------------------------------------------------------
     Code    Definition
     ------------------------------------------------------------------------
      0      Directory has been successfully removed.
     -3      Access path not found or directory not empty.
     -5      Access denied (e.g., in a network)
     -16     Current directory (cannot be removed)
     ------------------------------------------------------------------------

 Description

     DIRREMOVE() removes a designated directory.  This frees up the memory
     disk that an empty subdirectory occupies.

 Notes

     .  Use a drive designator and access path with <cDirectory>,
        wildcards are not permitted.

     .  The directory must be empty before you can remove it.

 Examples

     Remove the "\DATA" directory:

     IF DIRREMOVE("\DATA") == 0
        ? "Directory deleted."
     ENDIF

See Also: DIRCHANGE() DIRMAKE() DIRNAME()

CT_DIRNAME

 DIRNAME()
 Determines the name of the current directory
------------------------------------------------------------------------------
 Syntax

     DIRNAME([<cDrive>]) --> cDirectory

 Argument

     <cDrive>  Designates the drive for which the current directory is
     determined (a colon is unnecessary).  The default is the current drive.

 Returns

     DIRNAME() returns the current directory name on the <cDrive>.

 Description

     DIRNAME() determines the current directory name on the selected drive.
     You can use this function to construct complete access paths.

 Notes

     .  The maximum length of the returned value is 65 characters.  If
        no drive designator is specified, the current drive is assumed.

     .  If there is an invalid drive designation, DIRNAME() returns a
        null string.

 Examples

     .  Display the current directory name:

        ? "Current Directory:  " + DIRNAME()

     .  With a drive designator:

        ? DIRNAME("A")               // Current directory on Drive A:

See Also: DIRCHANGE() DIRMAKE() DIRREMOVE()