Variable Management Functions

Variable Management

FieldBlock Return a code block that sets/gets a value for a given field
FieldWBlock Return a sets/gets code block for field in a given work area
HB_AParams Returns an array containing values of all parameters passed to a function, method or procedure
HB_ArgC Returns the number of command line arguments
HB_ArgCheck Checks existence of an internal switch on the command line
HB_ArgShift Updates HB_Arg* parameter list removing the 1-st one and replacing it by others
HB_ArgString Retrieves the vale of an internal switch set on the command line.
HB_ArgV Retrieves the value of a command line argument
HB_PIsByRef Determine if a parameter is passed by reference.
HB_PValue Retrieves the value of an argument.
HB_ValToStr Converts any scalar type to a string.
MemVarBlock Returns a codeblock that sets/gets a value of memvar variable
PCount Retrieves the number of arguments passed to a function.
Type Retrieves the type of an expression
ValType Retrieves the data type of an expression

MemVarBlock()

MEMVARBLOCK()

Returns a codeblock that sets/gets a value of memvar variable

Syntax

      MEMVARBLOCK( <cMemvarName> ) --> <bBlock>

Arguments

<cMemvarName> – a string that contains the name of variable

Returns

<bBlock> a codeblock that sets/get the value of variable

Description

This function returns a codeblock that sets/gets the value of PRIVATE or PUBLIC variable. When this codeblock is evaluated without any parameters passed then it returns the current value of given variable. If the second parameter is passed for the codeblock evaluation then its value is used to set the new value of given variable – the passed value is also returned as a value of the codeblock evaluation.

Examples

      PROCEDURE Main()
         LOCAL cbSetGet
         PUBLIC xPublic

         cbSetGet := MEMVARBLOCK( "xPublic" )
         EVAL( cbSetGet, "new value" )
         ? "Value of xPublic variable", EVAL( cbSetGet )

         RETURN

Compliance

Clipper

Seealso

__MVGET(), __MVPUT()

Files

Library is rtl

__mvPut()

Template

Function

Name

__mvPut()

Category

API

Subcategory

Variable management

Oneliner

This function set the value of memory variable

Syntax

      __mvGet( <cVarName> [, <xValue>] )  --> <xValue>

Arguments

<cVarName> – string that specifies the name of variable <xValue> – a value of any type that will be set – if it is not specified then NIL is assumed

Returns

<xValue> A value assigned to the given variable.

Description

This function sets the value of PRIVATE or PUBLIC variable if this variable exists otherwise it generates a runtime error. The variable is specified by its name passed as the function parameter. If a value is not specified then the NIL is assumed

Examples

      FUNCTION MemVarBlock( cMemvar )
         RETURN {| x | ;
            iif( PCount() == 0, ;
               __mvGet( cMemvar ), ;
               __mvPut( cMemvar, x ) ) }

Compliance

Harbour

Files

Library is core

Seealso

__mvGet()

__mvGet()

Template

Function

Name

__mvGet()

Category

API

Subcategory

Variable management

Oneliner

This function returns value of memory variable

Syntax

      __mvGet( <cVarName> )  --> <xVar>

Arguments

<cVarName> – string that specifies the name of variable

Returns

<xVar> The value of variable

Description

This function returns the value of PRIVATE or PUBLIC variable if this variable exists otherwise it generates a runtime error. The variable is specified by its name passed as the function parameter.

Examples

      FUNCTION MemVarBlock( cMemvar )
         RETURN {| x | ;
            iif( PCount() == 0, ;
               __mvGet( cMemvar ), ;
               __mvPut( cMemvar, x ) ) }

Compliance

Harbour

Seealso

__mvPut()

Files

Library is core