xHarbour Reference Documentation > Function Reference |
Creates a set/get code block for a dynamic memory variable.
MemVarBlock( <cMemVarName> ) --> bMemVarBlock
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.
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.
See also: | FieldBlock(), FieldWBlock() |
Category: | Code block functions |
Source: | rtl\memvabl.prg |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// 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
http://www.xHarbour.com