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


PCount()

PCOUNT()

Retrieves the number of arguments passed to a function.

Syntax

      PCOUNT() --> <nArgs>

Arguments

None

Returns

<nArgs> A number that indicates the number of arguments passed to a function or procedure.

Description

This function is useful to check if a function or procedure has received the required number of arguments.

Examples

      See Test

Tests

      PROCEDURE Test( xExp )
         IF PCount() == 0
            ? "This function needs a parameter"
         ELS
            ? xExp
         ENDIF
         RETURN

Compliance

Clipper

Files

Library is vm

Seealso

HB_PVALUE()

HB_PValue

HB_PVALUE

Retrieves the value of an argument.

Syntax

      HB_PVALUE( <nArg> ) --> <xExp>

Arguments

A number that indicates the argument to check.

Returns

<xExp> Returns the value stored by an argument.

Description

This function is useful to check the value stored in an argument.

Examples

      See Test

Tests

      PROCEDURE Test( nValue, cString )
         IF PCount() == 2
            ? hb_PValue( 1 ), nValue
            ? hb_PValue( 2 ), cString
         ENDIF
         RETURN

Compliance

Harbour

Files

Library is vm

Seealso

PCount(), HB_AParams()

C5_PCOUNT

 PCOUNT()
 Determine the position of the last actual parameter passed
------------------------------------------------------------------------------
 Syntax

     PCOUNT() --> nLastArgumentPos

 Returns

     PCOUNT() returns, as an integer numeric value, the position of the last
     argument passed.  If no arguments are passed, PCOUNT() returns zero.

 Description

     PCOUNT() reports the position of the last argument in the list of
     arguments passed when a procedure or user-defined function is invoked.
     This information is useful when determining whether arguments were left
     off the end of the argument list.  Arguments skipped in the middle of
     the list are still included in the value returned.

     To determine if a parameter did not receive a value, test it for NIL.
     Skipped parameters are uninitialized and, therefore, return NIL when
     accessed.  Another method is to test parameters with the VALTYPE()
     function.  This can establish whether the argument was passed and
     enforce the correct type at the same time.  If a parameter was not
     supplied, a default value can be assigned.

     For more information on passing parameters, refer to the "Basic
     Concepts" chapter in the Programming and Utilities Guide.

 Examples

     .  This example is a user-defined function that opens a database
        file and uses PCOUNT() to determine whether the calling procedure
        passed the name of the database file to be opened.  If the name was
        not passed, OpenFile() asks for the name:

        FUNCTION OpenFile( cFile )
           IF PCOUNT() = 0
              ACCEPT "File to use: " TO cFile
           ENDIF
           USE (cFile)
           RETURN (NETERR())

 Files   Library is CLIPPER.LIB.

See Also: DO* FUNCTION PARAMETERS PROCEDURE VALTYPE()

 

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