xHarbour Reference Documentation > Command Reference |
Deletes or resets dynamic memory variables.
RELEASE <memVarNames,...> RELEASE ALL [LIKE | EXCEPT <mask>]
The RELEASE command is used in two different ways. Either by specifying the exact symbolic name(s) of one or more dynamic memory variable(s), or by using a variable name's skeleton together with wildcard characters. The asterisk (*) matches multiple characters while the question mark matches any character at the same position.
As a general rule, the RELEASE command assigns NIL to the specified variables, it does not release their symbolic names immediately. This happens only when the releasing routine returns control to the calling routine.
The option ALL releases all currently visible dynamic variables. When combined either with LIKE (include) or with EXCEPT (exclude), followed by a skeleton specifying a group of variable names using wild card characters, the intended group of variables is selectively released.
GLOBAL, LOCAL and STATIC memory variables are not affected by CLEAR MEMORY.
See also: | CLEAR MEMORY, PRIVATE, PUBLIC, SAVE, RESTORE |
Category: | Memory commands |
Source: | vm\memvars.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates the effect of releasing PIVATE and // PUBLIC variables in a main and a sub-routine. PROCEDURE Main PRIVATE cPrivA := 11 , ; cPrivB := 22 PUBLIC cPubA := "Hello", ; cPubB := "World" ? cPrivA // result: 11 ? cPubA // result: Hello TestProc() ? cPrivA // result: NIL ? cPrivB // result: 22 ? cPubB // result: World ? cPubA // runtime error RETURN PROCEDURE TestProc() MEMVAR cPrivA, cPrivB PRIVATE cPrivA := 1000, ; cPrivB := 2000 ? cPrivA // result: 1000 ? cPrivB // result: 2000 RELEASE cPrivB ? cPrivA // result: 1000 ? cPrivB // result: NIL RELEASE ALL ? cPrivA // result: NIL ? cPrivB // result: NIL ? cPubA // result: Hello RELEASE cPubA ? Type("cPubA") // result: U RETURN
http://www.xHarbour.com