HB_FNameExists

HB_FNameExists

Tests for the existence of a file or a directory

Syntax

      File( <cFileSpec> ) --> lExists

Argument

<cFileSpec> : Exact file name to find

Returns

<lExists> : true (.T.) if the file exists or logical false (.F.)

Description

This function return a logical true (.T.) if the given filename <cFileSpec> exist

Note

HB_FNameExists() don’t accept wildcard characters

Example

      Assuming this directory tree and files exist :

      C:\
         | temp                     D
         + ---- + Dir1              D
                |      doc1.docx    F
                |      test1.bat    F
                |      test1.txt    F
                + Dir2              D
                       doc2.docx    F
                       test2.bat    F
                       test2.txt    F

      ? HB_FNameExists( 'C:\' )                        //  .T.
      ? HB_FNameExists( 'C:\*.*' )                     //  .F.
      ? HB_FNameExists( 'C:\temp\*.*' )                //  .F.
      ? HB_FNameExists( 'C:\temp\*.' )                 //  .F.
      ? HB_FNameExists( 'C:\temp\test*.*' )            //  .F.
      ? HB_FNameExists( 'C:\temp\test.bat' )           //  .T.
      ? HB_FNameExists( 'C:\temp\Dir' )                //  .F.
      ? HB_FNameExists( 'C:\temp\Dir*.*' )             //  .F.
      ? HB_FNameExists( 'C:\temp\Dir1' )               //  .T.
      ? HB_FNameExists( 'C:\temp\Dir1*' )              //  .F.
      ? HB_FNameExists( 'C:\temp\Dir2' )               //  .T.
      ? HB_FNameExists( 'C:\temp\Dir2*' )              //  .F.
      ? HB_FNameExists( 'C:\temp\Dir1\test1.*' )       //  .F.
      ? HB_FNameExists( 'C:\temp\Dir1\test1.bat' )     //  .T.
      ? HB_FNameExists( 'C:\temp\Dir1\*.bat' )         //  .F.

File

Library is rtl

Seealso:

SET DEFAULT, SET PATH, SET(), Directory(), File(), IsDirectory(), IsDir(), HB_FileExists(), HB_DirExists()

HB_FileExists

HB_FileExists

Tests for the existence of a file

Syntax

      HB_FileExists( <cFileSpec> ) --> <lExist>

Arguments

<cFileSpec> : A character string holding the relative or absolute name of a file

Return

<lFileExist> : .T. (true) when the file <cFileSpec> exists, otherwise .F. (false) is returned.

Description

The HB_FileExists() function is used to check if a file exists that matches the specification <lFileExist>.

This is a character string containing the absolute or relative path of a file.

Note

HB_FileExists() is a Harbour level function to check for the existence of a file. This works better than FILE() in most situations, but it doesn’t accept any wildcards.

Example

      Assuming this directory tree and files exist :

      C:\
         | temp                     D
         + ---- + Dir1              D
                |      doc1.docx    F
                |      test1.bat    F
                |      test1.txt    F
                + Dir2              D
                       doc2.docx    F
                       test2.bat    F
                       test2.txt    F

      ? HB_FileExists( 'C:\' )                        //  .F.
      ? HB_FileExists( 'C:\*.*' )                     //  .F.
      ? HB_FileExists( 'C:\temp\*.*' )                //  .F.
      ? HB_FileExists( 'C:\temp\*.' )                 //  .F.
      ? HB_FileExists( 'C:\temp\test*.*' )            //  .F.
      ? HB_FileExists( 'C:\temp\test.bat' )           //  .T.
      ? HB_FileExists( 'C:\temp\Dir' )                //  .F.
      ? HB_FileExists( 'C:\temp\Dir*.*' )             //  .F.
      ? HB_FileExists( 'C:\temp\Dir1' )               //  .F.
      ? HB_FileExists( 'C:\temp\Dir1*' )              //  .F.
      ? HB_FileExists( 'C:\temp\Dir2' )               //  .F.
      ? HB_FileExists( 'C:\temp\Dir2*' )              //  .F.
      ? HB_FileExists( 'C:\temp\Dir1\test1.*' )       //  .F.
      ? HB_FileExists( 'C:\temp\Dir1\test1.bat' )     //  .T.
      ? HB_FileExists( 'C:\temp\Dir1\*.bat' )         //  .F.

Seealso

SET DEFAULT, SET PATH, SET(), Directory(), File(),  IsDirectory(), IsDir(), HB_FNameExists(), HB_DirExists()

TYPE

Display the contents of a text file

Syntax

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

Arguments

<xcFile> is the name of the file, including extension, to be displayed to the screen. This argument may be specified as a literal file name or as a character expression enclosed in parentheses. <xcFile> must be specified with an extension if it has one.

TO PRINTER echoes the display to the printer.

TO FILE <xcOutFile> echoes the display to the specified file. <xcOutFile> may be specified either as a literal file name or as a character expression enclosed in parentheses. If no extension is specified, .txt is added.

Description

TYPE is a console command that displays the contents of a text file to the screen, optionally echoing the display to the printer and/or another text file. To suppress output to the screen while printing or echoing output to a file, SET CONSOLE OFF before the TYPE invocation.

If <xcFile> is specified without a path and/or drive designator, TYPE searches the current DEFAULT directory, and then, the current PATH. If <xcOutFile> is specified without a path and/or drive designator, TYPE creates the file in the current DEFAULT directory.

TYPE performs no special formatting on the listing. There are no special headings or pagination when the output is sent to the printer.

To pause output, use Ctrl-S. Note that you cannot interrupt a listing with Esc.

Examples

      .  This example illustrates the TYPE command:

      TYPE Main.prg TO PRINTER

Seealso

COPY FILE, SET DEFAULT, SET PATH, SET PRINTER

SET DEFAULT

SET DEFAULT

Establishes the Harbour search drive and directory.

Syntax

      SET DEFAULT TO [<cPath>]

Arguments

<cPath> Drive and/or path.

Description

This command changes the drive and directory used for reading and writing database, index, memory, and alternate files. Specifying no parameters with this command will default the operation to the current logged drive and directory.

Examples

      SET DEFAULT TO C:\temp

Compliance

Clipper

Seealso

SET PATH, CurDir(), Set()

TYPE

TYPE

Show the content of a file on the console, printer or file

Syntax

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

Arguments

<xcFile> is a name of the file to display. If the file have an extension, it must be specified (there is no default value). It can be specified as literal file name or as a character expression enclosed in parentheses.

TO PRINTER is an optional keyword that specifies that the output should go to both the screen and printer.

TO FILE <xcDestFile> copy the source <xcFile> also to a file. If no extension is given (.txt) is added to the output file name. <xcDestFile> can be specified as literal file name or as a character expression enclosed in parentheses.

Description

TYPE command type the content of a text file on the screen with an option to send this information also to the printer or to an alternate file. The file is displayed as is without any headings or formatting.

If <xcFile> contain no path, TYPE try to find the file first in the SET DEFAULT directory and then in search all of the SET PATH directories. If <xcFile> can not be found a run-time error occur.

If <xcDestFile> contain no path it is created in the SET DEFAULT directory.

Use SET CONSOLE OFF to suppress screen output. You can pause the output using Ctrl-S, press any key to resume.

Examples

      The following examples assume a file name mytext.dat exist in all
      specified paths,  a run-time error would displayed if it does not

      // display mytext.dat file on screen
      TYPE mytext.dat

      // display mytext.dat file on screen and printer
      TYPE mytext.dat TO PRINTER

      // display mytext.dat file on printer only
      SET CONSOLE OFF
      TYPE mytext.dat TO PRINTER
      SET CONSOLE ON

      // display mytext.dat file on screen and into a file myreport.txt
      TYPE mytext.dat TO FILE MyReport

Compliance

Clipper

Seealso

COPY FILE, SET DEFAULT, SET PATH, SET PRINTER, __TypeFile()

File()

File

Tests for the existence of file(s)

Syntax

      File( <cFileSpec> ) --> lExists

Argument

<cFileSpec> DOS skeleton (mask) or file name to find

Returns

<lExists> : true (.T.) if the file exists or logical false (.F.)

Description

This function return a logical true (.T.) if the given filename <cFileSpec> exist. DOS skeletons symbols may be used in the filename in <cFileSpec>, as may the drive and/or path name. If a path is not explicitly specified, File() will look for the file in the SET DEFAULT path, then in each SET PATH path, until the file is found or there are no more paths to search. The DOS PATH is never searched and the current drive/directory is only searched if SET DEFAULT is blank.

Example

      Assuming this directory tree and files exist :

      C:\
         | temp                     D
         + ---- + Dir1              D
                |      doc1.docx    F
                |      test1.bat    F
                |      test1.txt    F
                + Dir2              D
                       doc2.docx    F
                       test2.bat    F
                       test2.txt    F

      ? File( 'C:\' )                        //  .F.
      ? File( 'C:\*.*' )                     //  .T.
      ? File( 'C:\temp\*.*' )                //  .T.
      ? File( 'C:\temp\*.' )                 //  .F.
      ? File( 'C:\temp\test*.*' )            //  .T.
      ? File( 'C:\temp\test.bat' )           //  .T.
      ? File( 'C:\temp\Dir' )                //  .F.
      ? File( 'C:\temp\Dir*.*' )             //  .F.
      ? File( 'C:\temp\Dir1' )               //  .F.
      ? File( 'C:\temp\Dir1*' )              //  .F.
      ? File( 'C:\temp\Dir2' )               //  .F.
      ? File( 'C:\temp\Dir2*' )              //  .F.
      ? File( 'C:\temp\Dir1\test1.*' )       //  .T.
      ? File( 'C:\temp\Dir1\test1.bat' )     //  .T.
      ? File( 'C:\temp\Dir1\*.bat' )         //  .T.

Compliance

Cl*pper v5.2

File

Library is rtl

See also:

SET DEFAULT, SET PATH, SET(), IsDirectory(), IsDir(), HB_FileExists(), HB_FNameExists(), HB_DirExists()

__TypeFile()

Template

Function

Name

__TypeFile()

Category

API

Subcategory

Terminal

Oneliner

Show the content of a file on the console and/or printer

Syntax

      __TypeFile( <cFile>,  [<lPrint>] ) --> NIL

Arguments

<cFile> is a name of the file to display. If the file have an extension, it must be specified (there is no default value).

<lPrint> is an optional logical value that specifies whether the output should go only to the screen (.F.) or to both the screen and printer (.T.), the default is (.F.).

Returns

__TypeFile() always return NIL.

Description

__TypeFile() function type the content of a text file on the screen with an option to send this information also to the printer. The file is displayed as is without any headings or formatting.

If <cFile> contain no path, __TypeFile() try to find the file first in the SET DEFAULT directory and then in search all of the SET PATH directories. If <cFile> can not be found a run-time error occur.

Use SET CONSOLE OFF to suppress screen output.

You can pause the output using Ctrl-S, press any key to resume.

__TypeFile() function is used in the preprocessing of the TYPE command.

Examples

      The following examples assume a file name mytext.dat exist in all
      specified paths,  a run-time error would displayed if it does not

      // display mytext.dat file on screen
      __TypeFile( "mytext.dat" )

      // display mytext.dat file on screen and printer
      __TypeFile( "mytext.dat",  .T. )

      // display mytext.dat file on printer only
      SET CONSOLE OFF
      __TypeFile( "mytext.dat",  .T. )
      SET CONSOLE ON

Compliance

Clipper

Files

Library is core

Seealso

COPY FILE, SET DEFAULT, SET PATH, SET PRINTER, TYPE

C5_SET PATH

SET PATH
 Specify the Clipper search path for opening files
------------------------------------------------------------------------------
 Syntax

     SET PATH TO [<xcPathspec list>]

 Arguments

     TO <xcPathspec list> identifies the paths Clipper uses when
     searching for a file not found in the current directory.  You can
     specify it as a literal list or as a character expression enclosed in
     parentheses.  The list of paths can be separated by commas or
     semicolons.  However, continuation of a SET PATH command line with a
     semicolon is not supported unless <xcPathspec> is specified as a
     character expression enclosed in parentheses.

 Description

     SET PATH allows commands and functions that open database and associated
     files to find and open existing files in another drive and/or directory.
     It does this by specifying a path list to search if a referenced file
     cannot be found in the DEFAULT or specified directory.  Note that memo
     and low-level file functions respect neither the DEFAULT nor the path
     setting.

     A path is a pointer to a directory.  It consists of an optional drive
     letter and colon, followed by a list of directories from the root to the
     desired directory separated by backslash (\) characters.  A path list is
     the sequence of paths to search, each separated by a comma or semicolon.

     When you attempt to access a file, Clipper first searches the default
     drive and directory.  The default disk drive and directory are
     established by DOS when your Clipper application is loaded or, during
     execution, by SET DEFAULT.  If the file is not found, Clipper then
     searches each path in the specified path list until the first occurrence
     of the file is found.

     To create new files in another drive or directory, use SET DEFAULT TO
     <xcPathspec> or explicitly declare the path when specifying a new file
     name.

     SET PATH TO with no argument releases the path list and Clipper
     searches only the DEFAULT directory.

 Examples

     .  This example is a typical PATH command:

        SET PATH TO A:\INVENTORY;B:\VENDORS

     .  This example configures a path setting at runtime by passing a
        DOS environment variable to a program, retrieving its value with
        GETENV(), and then setting path with this value.  For example, in
        DOS:

        SET CLIP_PATH=C:\APPS\DATA,C:\APPS\PROGS

        Later in the configuration section of your application program:

        SET PATH TO (GETENV("CLIP_PATH"))

 Files   Library is CLIPPER.LIB.

See Also: CURDIR() SET DEFAULT



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 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