xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

RELEASE

Deletes or resets dynamic memory variables.

Syntax

RELEASE <memVarNames,...>
RELEASE ALL [LIKE | EXCEPT <mask>]

Arguments

<memVarNames,...>
A comma separated list of symbolic names of PRIVATE and/or PUBLIC variables to release.
ALL [LIKE|EXCEPT <mask>]
Mask to define the variable names of visible dynamic memory variables to include or exclude from releasing. <mask> can be specified using the wildcard characters (*) and (?).

Description

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.

Info

See also:CLEAR MEMORY, PRIVATE, PUBLIC, SAVE, RESTORE
Category: Memory commands
Source:vm\memvars.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

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