SET PROCEDURE

SET PROCEDURE*

Compile procedures and functions into the current object (.OBJ) file

Syntax

      SET PROCEDURE TO [<idProgramFile>[.<ext>]]

Arguments

TO <idProgramFile> is the name of the procedure file to compile into the current object file. It can optionally include a path and/or drive designator.

<ext> is the optional extension of the procedure. If not specified, .prg is assumed.

SET PROCEDURE TO with no argument is ignored.

Description

SET PROCEDURE directs the compiler to compile all procedures and user- defined functions declared within the specified procedure file into the current object (.OBJ) file.

SET PROCEDURE is a compatibility command and not recommended. It has been superseded by other facilities more appropriate to the compiled environment (e.g., the compiler script (.clp)) file.

See the Clipper “Compiler” chapter in the Programming and Utilities Guide for a full discussion of program architecture and configuration.

Seealso

#include, DO*, FUNCTION, PROCEDURE, RETURN

Advertisements

Harbour All Functions – D

Date()
Day()
Days()

DaysInMonth()
DaysToMonth()

dbAppend()
dbClearFilter()
dbCloseAll()
dbCloseArea()
dbCommit()
dbCommitAll()
dbCreate()
dbDelete()
dbEval()
dbF()
dbFilter()
dbGoBottom()
dbGoTo()
dbGoTop()
dbReCall()
dbRLock()
dbRLockList()
dbRUnlock()
dbSeek()
dbSelectArea()
dbSetDriver()
dbSetFilter()
dbSkip()
dbSkipper()
dbStruct()
dbUnlock()
dbUnlockAll()
dbUseArea()

DecToBin()
DecToHexa()
DecToOctal()

Deleted()
Descend()
DevOutPict()
DirChange()
DirRemove()
DiskSpace()

DMY()
Do()
DoW()

DOY
DToC()

DToR
DToS()

Harbour hvm Functions

Harbour Virtual Machine Functions

AEval Evaluates the subscript element of an array
CLIPINIT Initialize various Harbour sub-systems
dbEval Performs a code block operation on the current Database
Do Calls a procedure or a function
Eval Evaluate a code block
HB_PValue Retrieves the value of an argument
HB_ForNext Inline FOR…NEXT loop
PCount Retrieves the number of arguments passed to a function
ProcFile This function allways returns an empty string
ProcLine Gets the line number of the current function on the stack
ProcName Gets the name of the current function on the stack


Do()

DO()

Calls a procedure or a function

Syntax

      DO( <xFuncProc> [, <xArguments...>] ) --> <xRetVal>

Arguments

<xFuncProc> = Either a string with a function/procedure name to be called or a codeblock to evaluate.

<xArguments> = arguments passed to a called function/procedure or to a codeblock.

Returns

<xRetVal> A value that was returned from called function.

Description

This function can be called either by the harbour compiler or by user. The compiler always passes the item of IT_SYMBOL type that stores the name of procedure specified in DO <proc> WITH … statement.

If called procedure/function doesn’t exist then a runtime error is generated.

This function can be used as replacement of macro operator. It is also used internally to implement DO <proc> WITH <args…> In this case <xFuncProc> is of type HB_SYMB.

Examples

      cbCode := {| x | MyFunc( x ) }
      Do( cbCode, 1 )

      cFunction := "MyFunc"
      xRetVal := Do( cFunction, 2 )

      // Old style (slower):
      DO &cFunction WITH 3

Compliance

Clipper

Files

Library is rtl

C5_DO

DO*
 Call a procedure
------------------------------------------------------------------------------
 Syntax

     DO <idProcedure> [WITH <argument list>]

 Arguments

     <idProcedure> is the name of the procedure or user-defined function
     to be executed.

     WITH <argument list> specifies up to 128 arguments, separated by
     commas, to pass to <idProcedure>.  Each argument may be a single
     variable, field, array, array element, expression, or object.  Arguments
     can be skipped or left off the end of the list.

 Description

     The DO statement calls a procedure or user-defined function, optionally
     passing arguments to the called routine.  It performs the same action as
     a user-defined function or procedure specified on a line by itself with
     the exception that variables other than field variables are passed by
     reference as the default.  In order to pass a field variable as an
     argument, enclose it in parentheses, unless you declare it with the
     FIELD statement or with an alias.

     In Clipper, the number of specified arguments need not match the
     number of specified parameters in the called procedure.  If the number
     of arguments is less than the number of parameters, the parameter
     variables with no corresponding arguments are initialized with a NIL
     value when the procedure is called.  If the number of arguments is
     greater than the number of parameters, they are ignored.

     Also, skipping an argument within the <argument list> by leaving an
     empty spot next to the comma initializes the corresponding argument to
     NIL.  To detect the position of the last argument passed in the
     <argument list>, use PCOUNT().  To detect a skipped argument, compare
     the receiving parameter to NIL.

     In addition to calling a procedure or user-defined function, DO also has
     an effect on compilation if you compile the current program file without
     the /M option.  If the Clipper compiler encounters a DO statement and
     the specified procedure has not already been compiled, the compiler
     searches the current directory for a .prg file with the same name and
     compiles it.  If the file with the same name as the procedure is not
     found, the called procedure is assumed to be external, and a reference
     is added to the object (.OBJ) file.  At link time, the linker will
     search other object files and libraries for this external reference.

     In Clipper, DO is a compatibility statement and therefore not
     recommended.  Calling a procedure or function on a line by itself is the
     preferred method.  Since this preferred calling convention normally
     passes parameters by value, you must preface an argument with the pass-
     by-reference operator (@) in order to pass by reference.  If you are
     using DO to make a procedure call more readable, a user-defined command,
     specified with the #command directive, can provide greater readability
     without sacrificing the safety of variables passed as parameters.

     For more information on passing parameters refer to the Functions and
     Procedures section of the "Basic Concepts" chapter in the Programming
     and Utilities Guide.

 Examples

     .  This example executes a procedure with no parameters:

        DO AcctsRpt
        AcctsRpt()                           // Preferred method

     .  This example executes a procedure passing two constants:

        DO QtrRpt WITH "2nd", "Sales Division"
        QtrRpt("2nd", "Sales Division")      // Preferred method

     .  In this example, a procedure is executed with the first
        argument passed by value and the second passed by reference:

        nNumber := 12
        DO YearRpt WITH nNumber + 12, nNumber
        YearRpt(nNumber + 12, @nNumber)      // Preferred method

     .  Here, a procedure is invoked with skipped arguments embedded
        in the list of arguments:

        DO DisplayWindow WITH ,,,,"My Window"
        DisplayWindow(,,,,"My Window")       // Preferred method

See Also: FUNCTION LOCAL PARAMETERS PRIVATE PROCEDURE PUBLIC



C5 Flow Control Commands, Statements and Funtions

Commands :

CALL* :

Execute a C or Assembler procedure

CALL <idProcedure> [WITH <exp list>]

CANCEL* :

Terminate program processing

CANCEL* | QUIT

DO* :

Call a procedure

DO <idProcedure> [WITH <argument list>]

QUIT

Terminate program processing

QUIT | CANCEL*

RUN :

Execute a DOS command or program

RUN | !* <xcCommandLine>

SET KEY :

Assign a procedure invocation to a key

SET KEY <nInkeyCode> TO [<idProcedure>]

SET PROCEDURE *:

Compile procedures/functions into the current .OBJ file

SET PROCEDURE TO [<idProgramFile>[.<ext>]]

WAIT* :

Suspend program processing until a key is pressed

WAIT [<expPrompt>] [TO <idVar>]

Statements :

ANNOUNCE :

Declare a module identifier

ANNOUNCE <idModule>

 BEGIN SEQUENCE :

Define a sequence of statements for a BREAK

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

DO CASE :

Execute one of several alternative blocks of statements

DO CASE
   CASE <lCondition1>
       <statements>...
   [CASE <lCondition2>]
       <statements>...
   [OTHERWISE]
       <statements>...
END[CASE]

DO WHILE :

Execute a loop while a condition is true (.T.)

[DO] WHILE <lCondition>
    <statements>...
    [EXIT]
    <statements>...
    [LOOP]
    <statements>...
END[DO]

EXIT PROCEDURE :

Declare an exit procedure

EXIT PROCEDURE <idProcedure>
    [FIELD <idField list> [IN <idAlias>]]
    [LOCAL <identifier> [[:= <initializer>]]]
    [MEMVAR <identifer list>]
    .
    . <executable statements>
    .
[RETURN]

EXTERNAL* :

Declare a list of procedure or user-defined function names

EXTERNAL <idProcedure list>

FOR :

Execute a block of statements a specified number of times

FOR <idCounter> := <nStart> TO <nEnd> [STEP <nIncrement>]
    <statements>...
    [EXIT]
    <statements>...
    [LOOP]
NEXT

FUNCTION :

Declare a user-defined function name and formal parameters

[STATIC] FUNCTION <idFunction>[(<idParam list>)]
    [LOCAL <identifier> [[:= <initializer>], ... ]]
    [STATIC <identifier> [[:= <initializer>], ... ]]
    [FIELD <identifier list> [IN <idAlias>]]
    [MEMVAR <identifier list>]
    .
    . <executable statements>
    .
RETURN <exp>

IF :

Execute one of several alternative blocks of statements

IF <lCondition1>
    <statements>...
[ELSEIF <lCondition2>]
    <statements>...
[ELSE]
    <statements>...
END[IF]

INIT PROCEDURE :

Declare an initialization procedure

INIT PROCEDURE <idProcedure> [(<idParam list>)]
    [FIELD <idField list> [IN <idAlias>]]
    [LOCAL <identifier> [[:= <initializer>]]]
    [MEMVAR <identifer list>]
    .
    . <executable statements>
    .
[RETURN]

NOTE :

Place a single-line comment in a program file

NOTE This is a comment line

PARAMETERS :

Create private parameter variables

PARAMETERS <idPrivate list>

PROCEDURE :

Declare a procedure name and formal parameters

[STATIC] PROCEDURE <idProcedure> [(<idParam list>)]
    [FIELD <idField list> [IN <idAlias>]
    [LOCAL <identifier> [[:= <initializer>], ... ]]
    [MEMVAR <identifier list>]
    [STATIC <identifier> [[:= <initializer>], ... ]]
    .
    . <executable statements>
    .
[RETURN]

REQUEST :

Declare a module request list

REQUEST <idModule list>

RETURN :

Terminate a procedure, user-defined function or program

RETURN [<exp>]

Functions :

BREAK() :

Branch out of a BEGIN SEQUENCE…END construct

BREAK(<exp>) --> NIL

EVAL() :

Evaluate a code block

EVAL(<bBlock>, [<BlockArg list>]) --> LastBlockValue

IF() :

Return the result of an expression based on a condition

[I]IF(<lCondition>, <expTrue>, <expFalse>) --> Value

PCOUNT() :

Determine the position of the last actual parameter passed

PCOUNT() --> nLastArgumentPos

SETKEY() :

Assign an action block to a key

SETKEY(<nInkeyCode>, [<bAction>]) --> bCurrentAction

SETCANCEL() :

Toggle Alt-C and Ctrl-Break as program termination keys

SETCANCEL([<lToggle>]) --> lCurrentSetting

WORD()* :

Convert CALL command numeric parameters from double to int

WORD(<nNumber>) --> NIL