DIR

DIR

Display listings of files

Syntax

      DIR [<cFileMask>]

Arguments

<cFileMask> File mask to include in the function return. It could contain path and standard wildcard characters as supported by your OS (like * and ?). If <cFileMask> contains no path, then SET DEFAULT path is used to display files in the mask.

Description

If no <cFileMask> is given, __Dir() display information about all *.dbf in the SET DEFAULT path, this information contain: file name, number of records, last update date and the size of each file.

If <cFileMask> is given, __Dir() list all files that match the mask with the following details: Name, Extension, Size, Date.

DIR command is preprocessed into __Dir() function during compile time.

__Dir() is a compatibility function, it is superseded by DIRECTORY() which returns all the information in a multidimensional array.

Examples

      DIR          // information for all DBF files in current directory

      dir   "*.dbf"          // list all DBF file in current directory

      // list all PRG files in Harbour Run-Time library
      // for DOS compatible operating systems
        Dir  "C:\harbour\source\rtl\*.prg"

      // list all files in the public section on a Unix like machine
        Dir  "/pub"

Compliance

Clipper

Platforms

All (LFN)

Seealso

ADIR(), DIRECTORY(), SET DEFAULT, __DIR()*

__Dir()

Template

Function

Name

__Dir()*

Category

API

Subcategory

FileSys

Oneliner

Display listings of files

Syntax

      __Dir( [<cFileMask>] ) --> NIL

Arguments

<cFileMask> File mask to include in the function return. It could contain path and standard wildcard characters as supported by your OS (like * and ?). If <cFileMask> contains no path, then SET  DEFAULT path is used to display files in the mask.

Returns

__Dir() always returns NIL.

Description

If no <cFileMask> is given, __Dir() displays information about all *.dbf in the SET DEFAULT path. This information contains: file name, number of records, last update date and the size of each file.

If <cFileMask> is given, __Dir() list all files that match the mask with the following details: Name, Extension, Size, Date.

DIR command is preprocessed into __Dir() function during compile time.

__Dir() is a compatibility function, it is superseded by Directory() which return all the information in a multidimensional array.

Examples

      __Dir()      // information for all DBF files in current directory

      __Dir( "*.dbf" )         // list all DBF file in current directory

      // list all PRG files in Harbour Run-Time library
      // for MS-DOS compatible operating systems
      __Dir( "src\rtl\*.prg" )

      // list all files in the public section on a Unix like machine
      __Dir( "/pub" )

Compliance

Clipper

Platforms

All(LFN)

Files

Library is core

Seealso

ADir(), Directory(), SET DEFAULT, DIR

C5_DIR

 DIR*
 Display a listing of files from a specified path
------------------------------------------------------------------------------
 Syntax

     DIR [<xcFileSpec>]

 Arguments

     <xcFileSpec> is a template that must be matched by displayed files
     and can include standard wildcard (* and ?) characters.  You can specify
     <xcFileSpec> as a literal file specification string or as a character
     expression enclosed in parentheses.

 Description

     DIR is a file command that displays a listing of files from the
     specified path in one of two formats depending on whether you specify
     the <xcFileSpec> argument.  If you do not specify a path, DIR displays a
     standard listing of database files from the current or specified
     directory.  The list includes the database file name, date of last
     update, and number of records.  Including the option <xcFileSpec>
     displays a list of all files in the specified directory.  This list
     includes the file name, extension, number of bytes, and date of last
     update.

     If no path is specified, DIR displays files from the current DOS drive
     and directory unless SET DEFAULT has been used to specify a new default
     directory.

     DIR is a compatibility command and therefore not recommended.  It is
     superseded by the DIRECTORY() function which returns an array of file
     information from a wildcard pattern.  Using this array, you can display
     file information to screen.

 Notes

     .  Directory picklists: To present directory information to the
        user, use ADIR() to return one or more arrays of directory
        information, and ACHOICE() to present a picklist to the user.

 Examples

     .  These examples display DOS and database files in the current
        directory:

        cFilespec := "*.*"
        DIR (cFilespec)            // Display all files
        DIR                        // Display all (.dbf) files
        DIR *.prg                  // Display all program files

 Files   Library is EXTEND.LIB.

See Also: DIRECTORY() SET DEFAULT DIR*



C5 Commands

 ?|??            Display one or more values to the console
 @...BOX         Draw a box on the screen
 @...CLEAR       Clear a rectangular region of the screen
 @...GET         Create a new Get object and display it
 @...PROMPT      Paint a menu item and define a message
 @...SAY         Display data at a specified screen or printer row and column
 @...TO          Draw a single- or double-line box
 ACCEPT*         Place keyboard input into a memory variable
 APPEND BLANK    Add a new record to the current database file
 APPEND FROM     Import records from a database (.dbf) file or ASCII text file
 AVERAGE         Average numeric expressions in the current work area
 CALL*           Execute a C or Assembler procedure
 CANCEL*         Terminate program processing
 CLEAR ALL*      Close files and release public and private variables
 CLEAR GETS      Release Get objects from the current GetList array
 CLEAR MEMORY    Release all public and private variables
 CLEAR SCREEN    Clear the screen and return the cursor home
 CLEAR TYPEAHEAD Empty the keyboard buffer
 CLOSE           Close a specific set of files
 COMMIT          Perform a solid-disk write for all active work areas
 CONTINUE        Resume a pending LOCATE
 COPY FILE       Copy a file to a new file or to a device
 COPY STRUCTURE  Copy the current .dbf structure to a new database (.dbf) file
 COPY STRU EXTE  Copy field definitions to a .dbf file
 COPY TO         Export records to a database (.dbf) file or ASCII text file
 COUNT           Tally records to a variable
 CREATE          Create an empty structure extended (.dbf) file
 CREATE FROM     Create a new .dbf file from a structure extended file
 DELETE          Mark records for deletion
 DELETE FILE     Remove a file from disk
 DELETE TAG      Delete a tag
 DIR*            Display a listing of files from a specified path
 DISPLAY         Display records to the console
 EJECT           Advance the printhead to top of form
 ERASE           Remove a file from disk
 FIND*           Search an index for a specified key value
 GO              Move the pointer to the specified identity
 INDEX           Create an index file
 INPUT*          Enter the result of an expression into a variable
 JOIN            Create a new database file by merging from two work areas
 KEYBOARD        Stuff a string into the keyboard buffer
 LABEL FORM      Display labels to the console
 LIST            List records to the console
 LOCATE          Search sequentially for a record matching a condition
 MENU TO         Execute a lightbar menu for defined PROMPTs
 NOTE*           Place a single-line comment in a program file
 PACK            Remove deleted records from a database file
 QUIT            Terminate program processing
 READ            Activate full-screen editing mode using Get objects
 RECALL          Restore records marked for deletion
 REINDEX         Rebuild open indexes in the current work area
 RELEASE         Delete public and private memory variables
 RENAME          Change the name of a file
 REPLACE         Assign new values to field variables
 REPORT FORM     Display a report to the console
 RESTORE         Retrieve memory variables from a memory (.mem) file
 RESTORE SCREEN* Display a saved screen
 RUN             Execute a DOS command or program
 SAVE            Save variables to a memory (.mem) file
 SAVE SCREEN*    Save the current screen to a buffer or variable
 SEEK            Search an order for a specified key value
 SELECT          Change the current work area
 SET ALTERNATE   Echo console output to a text file
 SET BELL        Toggle sounding of the bell during full-screen operations
 SET CENTURY     Modify the date format to include or omit century digits
 SET COLOR*      Define screen colors
 SET CONFIRM     Toggle required exit key to terminate GETs
 SET CONSOLE     Toggle console display to the screen
 SET CURSOR      Toggle the screen cursor on or off
 SET DATE        Set the date format for input and display
 SET DECIMALS    Set the number of decimal places to be displayed
 SET DEFAULT     Set the CA-Clipper default drive and directory
 SET DELETED     Toggle filtering of deleted records
 SET DELIMITERS  Toggle or define GET delimiters
 SET DESCENDING  Change the descending flag of the controlling order
 SET DEVICE      Direct @...SAYs to the screen or printer
 SET EPOCH       Control the interpretation of dates with no century digits
 SET ESCAPE      Toggle Esc as a READ exit key
 SET EXACT*      Toggle exact matches for character strings
 SET EXCLUSIVE*  Establish shared or exclusive USE of database files
 SET FILTER      Hide records not meeting a condition
 SET FIXED       Toggle fixing of the number of decimal digits displayed
 SET FORMAT*     Activate a format when READ is executed
 SET FUNCTION    Assign a character string to a function key
 SET INDEX       Open one or more order bags in the current work area
 SET INTENSITY   Toggle enhanced display of GETs and PROMPTs
 SET KEY         Assign a procedure invocation to a key
 SET MARGIN      Set the page offset for all printed output
 SET MEMOBLOCK   Change the block size for memo files
 SET MESSAGE     Set the @...PROMPT message line row
 SET OPTIMIZE    Change the setting that optimizes using open orders
 SET ORDER       Select the controlling order
 SET PATH        Specify the CA-Clipper search path for opening files
 SET PRINTER     Toggle echo of output to printer or set the print destination
 SET PROCEDURE*  Compile procedures and functions into the current object file
 SET RELATION    Relate two work areas by a key value or record number
 SET SCOPE       Change the boundaries for scoping keys in controlling order
 SET SCOPEBOTTOM Change bottom boundary for scoping keys in controlling order
 SET SCOPETOP    Change top boundary for scoping keys in controlling order
 SET SCOREBOARD  Toggle the message display from READ or MEMOEDIT()
 SET SOFTSEEK    Toggle relative seeking
 SET TYPEAHEAD   Set the size of the keyboard buffer
 SET UNIQUE*     Toggle inclusion of non-unique keys into an index
 SET WRAP*       Toggle wrapping of the highlight in menus
 SKIP            Move the record pointer to a new position
 SORT            Copy to a database (.dbf) file in sorted order
 STORE*          Assign a value to one or more variables
 SUM             Sum numeric expressions and assign results to variables
 TEXT*           Display a literal block of text
 TOTAL           Summarize records by key value to a database (.dbf) file
 TYPE            Display the contents of a text file
 UNLOCK          Release file/record locks set by the current user
 UPDATE          Update current database file from another database file
 USE             Open an existing database (.dbf) and its associated files
 WAIT*           Suspend program processing until a key is pressed
 ZAP             Remove all records from the current database file

 

C5_DIRCHANGE

 DIRCHANGE()
 Change the current DOS directory
------------------------------------------------------------------------------
 Syntax

     DIRCHANGE(<cDir>) --> nSuccess

 Arguments

     <cDir> is the name of the directory to change to, including the
     drive.

 Returns

     DIRCHANGE() returns 0 if successful; -1 if there is an argument error.
     Otherwise, DIRCHANGE() returns the DOS error code.

 Description

     DIRCHANGE() changes the current DOS directory.  This function may also
     be used to determine whether or not a directory exists.

 Examples

     .  The following example attempts to change to the "c:\dos"
        directory.  If it is unsuccessful, an error message is displayed.

        nResult :=  DIRCHANGE("c:\dos")

        IF nResult != 0
           ? "Cannot change directory. "
           DO CASE
              CASE nResult == 3
                 ?? "Directory does not exist."
              CASE nResult == 5
                 ?? "Access to directory denied."
           END
           BREAK
        ENDIF

       You may also use something like this:

        DIRCHANGE( "..\..\test" )

 Files   Library is EXTEND.LIB.

See Also: CURDIR(), DIR*, DIRMAKE(), DIRREMOVE(), DIRCHANGE()

C5 File Management

C5 File Management Commands and Functions

High Level :

ADIR()* :

Fill a series of arrays with directory information

ADIR( [ <cFilespec> ],
    [ <aFilenames> ],
    [ <aSizes> ],
    [ <aDates> ],
    [ <aTimes> ],
    [ <aAttributes> ] ) --> nFiles

CLOSE :

Close a specific set of files

CLOSE [ <idAlias> | ALL | ALTERNATE | DATABASES | FORMAT |INDEXES ]

COPY FILE :

Copy a file to a new file

COPY FILE <xcSourceFile> TO <xcTargetFile> | <xcDevice>

CURDIR() :

Return the current DOS directory

CURDIR( [ <cDrivespec> ] ) --> cDirectory

DELETE FILE :

Remove a file from disk

DELETE FILE | ERASE <xcFile>

DIR* :

Display a listing of files from a specified path

DIR [ <xcFileSpec> ]

        DIRCHANGE() :

      Change the current DOS directory

       DIRCHANGE(<cDir>) --> nSuccess

DIRECTORY() :

Create an array of directory and file information

DIRECTORY( <cDirSpec>, [ <cAttributes> ] ) --> aDirectory

 DIRMAKE()

         Create a directory

        DIRMAKE(<cNewDir>) --> nSuccess

          DIRREMOVE() :

     Remove a directory

       DIRREMOVE(<cDirName>) --> nSuccess

          DISKCHANGE() :

       Change the current DOS disk drive

        DISKCHANGE(<cDrive>) --> lSuccess

          DISKNAME() :

                  Return the current DOS drive

        DISKNAME() --> cDrive

DISKSPACE() :

Return the space available on a specified disk

DISKSPACE( [ <nDrive> ] ) --> nBytes

ERASE :

Remove a file from disk

ERASE | DELETE FILE <xcFile>

FILE() :

Determine if files exist in the default directory or path

FILE( <cFilespec> ) --> lExists

RENAME :

Change the name of a file

RENAME <xcOldFile> TO <xcNewFile>

SET ALTERNATE :

Echo console output to a text file

SET ALTERNATE TO [ <xcFile> [ADDITIVE]]
SET ALTERNATE on | OFF | <xlToggle>

SET DEFAULT :

Set the CA-Clipper default drive and directory

SET DEFAULT TO [ <xcPathspec> ]

SET PATH :

Specify the CA-Clipper search path for opening files

SET PATH TO [ <xcPathspec list> ]

TYPE :

Display the contents of a text file

TYPE <xcFile> [TO PRINTER] [TO FILE <xcOutFile> ]

Low-level :

FCLOSE() :

Close an open binary file and write DOS buffers to disk

FCLOSE( <nHandle> ) --> lError

FCREATE() :

Create and/or truncate a binary file to zero length

FCREATE( <cFile>, [ <nAttribute> ] ) --> nHandle

FERASE() :

Delete a file from disk

FERASE( <cFile> ) --> nSuccess

FERROR() :

Test for errors after a binary file operation

FERROR() --> nErrorCode

FOPEN() :

Open a binary file

FOPEN( <cFile>, [ <nMode> ] ) --> nHandle

FREAD() :

Read characters from a binary file into a buffer variable

FREAD( <nHandle>, @<cBufferVar>, <nBytes> ) --> nBytes

FREADSTR() :

Read characters from a binary file

FREADSTR( <nHandle>, <nBytes> ) --> cString

          FRENAME() :

Change the name of a file

       FRENAME( <cOldFile>, <cNewFile> ) --> nSuccess

FSEEK() :

Set a binary file pointer to a new position

FSEEK( <nHandle>, <nOffset>, [ <nOrigin> ] ) --> nPosition

FWRITE() :

Write to an open binary file

FWRITE( <nHandle>, <cBuffer>, [ <nBytes> ] )
    --> nBytesWritten

HEADER() :

Return the current database file header length

HEADER() --> nBytes