__mvScope()

Template

Function

Name

__mvScope()

Category

API

Subcategory

Variable management

Oneliner

If variable exists then returns its scope.

Syntax

      __mvScope( <cVarName> )

Arguments

<cVarName> = a string with a variable name to check

Returns

The symbolic values are defined in hbmemvar.ch

HB_MV_NOT_FOUND      = variable is not declared (not found in symbol table)
HB_MV_UNKNOWN        = if variable doesn't exist (but found in symbol table)
HB_MV_ERROR          = if information cannot be obtained (memory error or argument error)
HB_MV_PUBLIC         = for public variables
HB_MV_PRIVATE_GLOBAL = for private variables declared outside of current function/procedure
HB_MV_PRIVATE_LOCAL  = for private variables declared in current function/procedure

Examples

      PROCEDURE Main()
         PUBLIC mPublic
         PRIVATE mPrivateGlobal

         CallProc()
         ? __mvScope( "mPrivateLocal" )      // HB_MV_UNKNOWN

         RETURN

      PROCEDURE CallProc()
         PRIVATE mPrivateLocal

         ? __mvScope( "mPublic" )            // HB_MV_PUBLIC
         ? __mvScope( "mPrivateGlobal" )     // HB_MV_PRIVATE_GLOBAL
         ? __mvScope( "mPrivateLocal" )      // HB_MV_PRIVATE_LOCAL
         ? __mvScope( "mFindMe" )            // HB_MV_NOT_FOUND

         IF __mvScope( "mPublic" ) > HB_MV_ERROR
            ? "Variable exists"
         ELSE
            ? "Variable not created yet"
         ENDIF

         RETURN

Compliance

Harbour

Files

Library is core

Seealso

include/hbmemvar.ch

2 responses to “__mvScope()

  1. Pingback: Harbour Internal Functions | Viva Clipper !

  2. Pingback: Variable Management Functions | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.