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

__mvDbgInfo()

Template

Function

Name

__mvDbgInfo()

Category

API

Subcategory

Internal

Oneliner

This function returns the information about the variables for debugger

Syntax

      __mvDbgInfo( <nScope> [, <nPosition> [, @<cVarName>] ] )

Arguments

<nScope> = the scope of variables for which an information is asked Supported values (defined in hbmemvar.ch) HB_MV_PUBLIC HB_MV_PRIVATE (or any other value) <nPosition> = the position of asked variable on the list of variables with specified scope – it should start from position 1 <cVarName> = the value is filled with a variable name if passed by reference and <nPosition> is specified

Returns

The return value depends on the number of arguments passed

Description

This function retrieves the information about memvar variables. It returns either the number of variables with given scope (when the first argument is passed only) or a value of variable identified by its position in the variables’ list (when second argument is passed). It also returns the name of a variable if optional third argument is passed by reference.

If requested variable doesn’t exist (requested position is greater then the number of defined variables) then NIL value is returned and variable name is set to “?”

The dynamic symbols table is used to find a PUBLIC variable then the PUBLIC variables are always sorted alphabetically. The PRIVATE variables are sorted in the creation order.

Note:

Due to dynamic nature of memvar variables there is no guarantee that successive calls to retrieve the value of <Nth> PUBLIC variable will return the value of the same variable.

Examples

      #include "hbmemvar.ch"

      PROCEDURE Main()

         LOCAL nCount, i, xValue, cName

         nCount := __mvDbgInfo( HB_MV_PUBLIC )
         FOR i := 1 TO nCount
            xValue := __mvDbgInfo( HB_MV_PUBLIC, i, @cName )
            ? i, cName, xValue
         NEXT

         //

         ? "PUBLIC=", __mvDbgInfo( HB_MV_PUBLIC )
         ? "PRIVATE=", __mvDbgInfo( HB_MV_PRIVATE )

         PUBLIC cPublic := "cPublic in MAIN"

         ? "PUBLIC=", __mvDbgInfo( HB_MV_PUBLIC )
         ? "PRIVATE=", __mvDbgInfo( HB_MV_PRIVATE )

         PRIVATE cPrivate := "cPrivate in MAIN"

         ? "PUBLIC=", __mvDbgInfo( HB_MV_PUBLIC )
         ? "PRIVATE=", __mvDbgInfo( HB_MV_PRIVATE )

         CountMemvars()

         ? "Back in Main"
         ? "PUBLIC=", __mvDbgInfo( HB_MV_PUBLIC )
         ? "PRIVATE=", __mvDbgInfo( HB_MV_PRIVATE )

         RETURN

      PROCEDURE CountMemvars()
         LOCAL i, nCnt, xVal, cName
         PUBLIC ccPublic := "ccPublic"
         PRIVATE ccPrivate := "ccPrivate"

         ? "In CountMemvars"
         ? "PUBLIC=", __mvDbgInfo( HB_MV_PUBLIC )
         ? "PRIVATE=", __mvDbgInfo( HB_MV_PRIVATE )

         PRIVATE cPublic := "cPublic"

         ? "PUBLIC=", __mvDbgInfo( HB_MV_PUBLIC )
         ? "PRIVATE=", __mvDbgInfo( HB_MV_PRIVATE )

         nCnt := __mvDbgInfo( HB_MV_PRIVATE ) + 1
         FOR i := 1 TO nCnt
            xVal := __mvDbgInfo( HB_MV_PRIVATE, i, @cName )
            ? i, "=", cName, xVal
         NEXT

         nCnt := __mvDbgInfo( HB_MV_PUBLIC ) + 1
         FOR i := 1 TO nCnt
            xVal := __mvDbgInfo( HB_MV_PUBLIC, i, @cName )
            ? i, "=", cName, xVal
         NEXT

         RETURN

Compliance

This function should be called from the debugger only.

Files

Library is core