xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

MemVarBlock()

Creates a set/get code block for a dynamic memory variable.

Syntax

MemVarBlock( <cMemVarName> ) --> bMemVarBlock

Arguments

<cMemVarName>
A character string holding the name of a dynamic memory variable (PRIVATE or PUBLIC).

Return

The function returns a set/get code block that accesses the memory variable <cMemVarName>. If the variable does not exist, the return value is NIL.

Description

The function creates a code block accessing a dynamic memory variable, i.e. a variable of PRIVATE or PUBLIC scope. The code block accepts one parameter. If a parameter is passed, its value is assigned to the variable <cMemVarName>. Evaluating the code block without a parameter returns the value of the variable.

Info

See also:FieldBlock(), FieldWBlock()
Category: Code block functions
Source:rtl\memvabl.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example creates two code blocks accessing a PRIVATE
// and a PUBLIC variable.

   PROCEDURE Main
      MEMVAR cPrivate, cPublic
      LOCAL bMemVar1 , bMemVar2

      PUBLIC  cPublic  := "PUBLIC"
      PRIVATE cPrivate := "PRIVATE"

      bMemVar1 := MemVarBlock( "cPublic"  )
      bMemVar2 := MemVarBlock( "cPrivate" )

      ? Eval( bMemVar1 )             // result: PUBLIC
      ? Eval( bMemVar2 )             // result: PRIVATE

      ? Eval( bMemVar1, "Hello" )    // result: Hello
      ? Eval( bMemVar2, "World" )    // result: World

      ? cPublic                      // result: Hello
      ? cPrivate                     // result: World
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe