C5 Networking Commands and Functions

DBUNLOCK() :

Release all locks for the current workarea

DBUNLOCK() --> NIL

DBUNLOCKALL() :

Release all locks for all workareas

DBUNLOCKALL() --> NIL

FLOCK() :

Lock an open and shared database file

FLOCK() --> lSuccess

NETERR() :

Determine if a network command has failed

NETERR([<lNewError>]) --> lError

NETNAME() :

Return the current workstation identification

NETNAME() --> cWorkstationName

RLOCK() :

Lock the current record in the active work area

RLOCK() --> lSuccess

SET EXCLUSIVE

Establish shared or exclusive USE of database files

SET EXCLUSIVE ON | off | <xlToggle>

UNLOCK :

Release file record locks set by the current user

UNLOCK [ALL]

CL5 Printing Commands, Statements and Funtions

?/?? :

Display or print one or more values to the console or printer

? | ?? [<exp list>]

@…SAY :

Display or print data at a specified screen or printer row and column

@ <nRow>, <nCol>
   [SAY <exp>
   [PICTURE <cSayPicture>]
   [COLOR <cColorString>]]
   [GET <idVar>
   [PICTURE <cGetPicture>]
   [COLOR <cColorString>]]
   [WHEN <lPreExpression>]
   [RANGE* <dnLower>, <dnUpper>] |
   [VALID <lPostExpression>]

DEVPOS() :

Move the cursor or printhead to a new position depending on the current device

DEVPOS(<nRow>, <nCol>) --> NIL

DISPLAY :

Display or print records to the console or printer

DISPLAY <exp list>
   [TO PRINTER] [TO FILE <xcFile>]
   [<scope>] [WHILE <lCondition>]
   [FOR <lCondition>] [OFF]

EJECT :

Advance the print head to top of form

EJECT

ISPRINTER() :

Determine whether the LPT1 is ready

ISPRINTER() --> lReady

LABEL FORM :

Display or print labels to the console or printer

LABEL FORM <xcLabel>
   [TO PRINTER] [TO FILE <xcFile>] [NOCONSOLE]
   [<scope>] [WHILE <lCondition>] [FOR <lCondition>]
   [SAMPLE]

LIST :

List or print records to the console or printer

LIST <exp list>
   [TO PRINTER] [TO FILE <xcFile>]
   [<scope>] [WHILE <lCondition>]
   [FOR <lCondition>] [OFF]

OUTSTD() :

Write a list of values to the standard output device

OUTSTD(<exp list>) --> NIL

PCOL() :

Return the current column position of the printhead

PCOL() --> nColumn

PROW() :

Return the current row position of the printhead

PROW() --> nRow

QOUT() :

Display or print a list of expressions to the console or printer

QOUT( [ <exp list> ] ) --> NIL
QQOUT( [ <exp list> ] ) --> NIL

REPORT FORM :

Display or print a report to the console or printer

REPORT FORM <xcReport>
   [TO PRINTER] [TO FILE <xcFile>] [NOCONSOLE]
   [<scope>] [WHILE <lCondition>] [FOR <lCondition>]
   [PLAIN | HEADING <cHeading>] [NOEJECT] [SUMMARY]

SET MARGIN :

Set the page offset for all printed pages

SET MARGIN TO [<nPageOffset>]

SET PRINTER :

Toggle echo of console output to the printer or set the destination of printed output

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

SETPRC() :

Set PROW() and PCOL() values

SETPRC(<nRow>, <nCol>) --> NIL

TYPE :

Display or print the contents of a text file

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

C5 Error Handling

C5 Error Handling Commands, Statements and Funtions

Statement :

BEGIN SEQUENCE :

Define a sequence of statements for a BREAK

BEGIN SEQUENCE
    <statements>...
    [BREAK [<exp>]]
    <statements>...
    [RECOVER [USING <idVar>]]
    <statements>...
END [SEQUENCE]

Functions :

ALTD() :

Invoke the Clipper Debugger

ALTD( [ <nAction> ] ) --> NIL

BREAK() :

Branch out of a BEGIN SEQUENCE…END construct

BREAK( <exp> ) --> NIL

DOSERROR() :

Return the DOS error number

DOSERROR( [ <nNewOsCode> ] ) --> nOsCode

ERRORBLOCK() :

Post a code block to execute when a runtime error occurs

ERRORBLOCK( [ <bErrorHandler> ] ) --> bCurrentErrorHandler

ERRORLEVEL() :

Set the Clipper return code

ERRORLEVEL( [ <nNewReturnCode> ] ) --> nCurrentReturnCode

NETERR() :

Determine if a network command has failed

NETERR( [ <lNewError> ] ) --> lError

OUTERR() :

Write a list of values to the standard error device

OUTERR( <exp list> ) --> NIL

PROCLINE() :

Return the source line number of the current or previous activation

PROCLINE( [ <nActivation> ] ) --> nSourceLine

PROCNAME() :

Return the name of the current or previous procedure or user-defined function

PROCNAME( [ <nActivation> ] ) --> cProcedureName

Error Class :

Provides objects containing information about runtime errors.

Description :

An Error object is a simple object that contains information pertaining to a runtime error. Error objects have no methods, only exported instance variables. When a runtime error occurs, CA-Clipper creates a new Error object and passes it as an argument to the error handler block specified with the ERRORBLOCK() function. Within the error handler, the Error object can then be queried to determine the nature of the error condition.

Error objects can also be returned to the RECOVER statement of a BEGIN SEQUENCE construct with a BREAK statement. Here, the error object can be queried for local error handling. For more detailed information and examples refer to the Error Handling Strategies chapter in the Programming and Utilities guide.

Class Function :

ErrorNew() :

Returns a new Error object.

ErrorNew() --> objError

Exported Instance Variables :

args (Assignable) :

An array of function or operator arguments.

Contains an array of the arguments supplied to an operator or function when an argument error occurs. For other types of errors, Error:args contains a NIL value.

canDefault (Assignable) :

Indicates whether or not default recovery is available.

Contains a logical value indicating whether the subsystem can perform default error recovery for the error condition. A value of true (.T.) indicates that default recovery is available. Availability of default handling and the actual default recovery strategy depends on the subsystem and the error condition. The minimum action is simply to ignore the error condition.

Default recovery is requested by returning false (.F.) from the error block invoked to handle the error. Note that Error:canDefault is never true (.T.) if Error:canSubstitute is true (.T.).

canRetry (Assignable) :

Indicates whether or not a retry is possible after an error.

Contains a logical value indicating whether the subsystem can retry the operation that caused the error condition. A value of true (.T.) indicates that a retry is possible. Retry may or may not be available, depending on the subsystem and the error condition.

Retry is requested by returning true (.T.) from the error block invoked to handle the error. Note that Error:canRetry never contains true (.T.) if Error:canSubstitute contains true (.T.).

canSubstitute (Assignable) :

Indicates if a new result can be substituted after an error

Contains a logical value indicating whether a new result can be substituted for the operation that produced the error condition. Argument errors and certain other simple errors allow the error handler to substitute a new result value for the failed operation. A value of true (.T.) means that substitution is possible.

The substitution is performed by returning the new result value from the code block invoked to handle the error. Note that Error:canSubstitute is never true (.T.) if either Error:canDefault or Error:canRetry is true (.T.).

cargo (Assignable) :

User-definable variable.

Contains a value of any data type unused by the Error system. It is provided as a user-definable slot, allowing arbitrary information to be attached to an Error object and retrieved later.

description (Assignable) :

Character description of the error condition.

Contains a character string that describes the error condition. A zero-length string indicates that the subsystem does not provide a printable description for the error. If Error:genCode is not zero, a printable description is always available.

filename (Assignable) :

Name of the file associated with the error

Contains a character value representing the name originally used to open the file associated with the error condition. A zero-length string indicates either that the error condition is not associated with a particular file or that the subsystem does not retain filename information.

genCode (Assignable) :

Error code number.

Contains an integer numeric value representing a CA-Clipper generic error code. Generic error codes allow default handling of similar errors from different subsystems. A value of zero indicates that the error condition is specific to the subsystem and does not correspond to any of the generic error codes. The header file, Error.ch, provides a set of manifest constants for generic error codes.

operation (Assignable) :

Character description of the failed operation.

Contains a character string that describes the operation being attempted when the error occurred. For operators and functions, Error:operation contains the name of the operator or function. For undefined variables or functions, it contains the name of the variable or function. A zero-length string indicates that the subsystem does not provide a printable description of the operation.

osCode (Assignable) :

Operating system error code number

Contains an integer numeric value representing the operating system error code associated with the error condition. A value of zero indicates that the error condition was not caused by an error from the operating system. When Error:osCode is set to a value other than zero DOSERROR() is updated with the same value.

Error:osCode properly reflects the DOS extended error code for file errors. This allows proper distinction between errors which result from sharing violations (e.g., opening EXCLUSIVE when another process has already opened the file) and access violations (e.g., opening read/write when the file is marked read-only).

For a list of DOS error codes please look at here 

severity (Assignable) :

Indicates error severity

Contains a numeric value indicating the severity of the error condition. Four standard values are defined in Error.ch:

Error:severity Values
------------------------------------------------------------
Error.ch        Meaning
------------------------------------------------------------
ES_WHOCARES     The condition does not represent a failure;
                the error is informational.
ES_WARNING      The condition does not prevent further
                operations, but may result in a more serious 
                error later. 
ES_ERROR        The condition prevents further operations without 
                corrective action of some kind. 
ES_CATASTROPHIC The condition requires immediate termination 
                of the application.
------------------------------------------------------------

Note that the Clipper runtime support code only generates errors with severities of ES_WARNING or ES_ERROR

subCode (Assignable) :

Subsystem-specific error code number.

Contains an integer numeric value representing a subsystem-specific error code. A value of zero indicates that the subsystem does not assign any particular number to the error condition.

subSystem (Assignable) :

Character description of the subsystem generating the error.

Contains a character string representing the name of the subsystem generating the error. For errors with basic CA-Clipper operators and functions, the subsystem name “BASE” is given. For errors generated by a database driver, Error:subSystem contains the name of the database driver

tries (Assignable) :

Number of times the failed operation has been attempted.

Contains an integer numeric value representing the number of times the failed operation has been attempted. When Error:canRetry is true (.T.), Error:tries can be used to limit the number of retry attempts. A value of zero indicates that the subsystem does not track the number of times the operation has been tried.

Examples :

. This example demonstrates how a file open operation might be handled in an error handler replicating the default CA-Clipper behavior. When, for example, an attempt to open a database file with a USE command fails, control returns to the statement following the offending command:

#include "Error.ch"
#command RETRY => RETURN (.T.) // Retry operation
#command RESUME => RETURN (.F.) // Default recovery
//
FUNCTION MyError( objError )
   //
   // Handle file open error
   IF objError:genCode == EG_OPEN .AND.;
      objError:canDefault .AND.;
      NETERR()
   //
      RESUME
   ENDIF
  .
  . <other error statements>
  .
RETURN NIL

. This example retries an operation within an error handler a specified number of times:

 #include "Error.ch"
 #command RETRY => RETURN (.T.) // Retry operation
 #command RESUME => RETURN (.F.) // Default recovery
 //
FUNCTION MyError( objError )

 // Handle printer not ready error
 IF objError:genCode == EG_PRINT .AND.;
    objError:canRetry .AND.;
    objError:tries < 25

    RETRY
 ENDIF
 .
 . <other error statements>
 .
 RETURN NIL

. This code fragment returns an error object from an error handler to the RECOVER statement for further processing:

LOCAL objLocal, bLastHandler
// Save current and set new error handler
bLastHandler := ERRORBLOCK({ |objErr| ;
MyHandler(objErr, .T.)})
BEGIN SEQUENCE
   .
   . <operation that might fail>
   .
   RECOVER USING objLocal
   .
   . <send messages to objLocal and handle the error>
   .
END
// Restore previous error handler
ERRORBLOCK( bLastHandler )
FUNCTION MyHandler( objError, lLocalHandler )

    // Handle locally returning the error object
    IF lLocalHandler
       BREAK objError
    ENDIF
    .
    . <other statements to handle the error>
    .
RETURN NIL

Files: Header file is Error.ch, default error handler is in Errorsys.prg.

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

C5 Environment Commands and Functions

Commands :

SET BELL :

Toggle automatic sounding of the bell during full-screen operations

SET BELL on | OFF | <xlToggle>

SET COLOR :

Define screen colors

SET COLOR | COLOUR TO [ [<standard>]
    [, <enhanced>] [, <border>] [, <background> ]
    [, <unselected>]] | ( <cColorString> )

SET DEFAULT :

Set the default drive and directory

SET DEFAULT TO [ <xcPathspec> ]

SET FUNCTION :

Assign a character string to a function key

SET FUNCTION <nFunctionKey> TO <cString>

SET TYPEAHEAD :

Set the size of the keyboard buffer

SET TYPEAHEAD TO <nKeyboardSize>

Functions :

CURDIR() :

Return the current DOS directory

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

DISKSPACE() :

Return the space available on a specified disk

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

FKLABEL()* :

Return function key name

FKLABEL( <nFunctionKey> ) --> cKeyLabel

FKMAX()* :

Return number of function keys as a constant

FKMAX() --> nFunctionKeys

GETENV() :

Retrieve the contents of a DOS environment variable

GETENV( <cEnvironmentVariable> ) --> cString

ISCOLOR() :

Determine if the current computer has color compatibility

ISCOLOR() | ISCOLOUR() --> lBoolean

MAXROW() :

Determine the maximum visible screen row

MAXROW() --> nRow

MAXCOL() :

Determine the maximum visible screen column

MAXCOL() --> nColumn

MEMORY() :

Determine the amount of available free pool memory

MEMORY( <nMemoryType> ) --> nKbytes

NOSNOW() :

Toggle snow position

NOSNOW( <lToggle> ) --> NIL

OS() :

Return the operating system name

OS() --> cOSName

SET() :

Inspect or change a global setting

SET( <nSpecifier>, [<expNewSetting>], [<lOpenMode> ] )
      --> CurrentSetting

TONE() :

Sound a speaker tone for a specified frequency and duration

TONE( <nFrequency>, <nDuration> ) --> NIL

VERSION() :

Returns Clipper Compiler version

VERSION() --> cVersion