xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_ResetWith()

Replaces the with object during WITH OBJECT execution.

Syntax

HB_ResetWith( <oObject> ) --> NIL

Arguments

<oObject>
This is an object which becomes the new with object in the current WITH OBJECT .. END context.

Return

The return value is always NIL.

Description

Function HB_ResetWith() replaces the current with object in the context of the WITH OBJECT statement. All abbreviated messages within the WITH OBJECT .. END block are addressed to this new with object.

In contrast to the HB_SetWith() function, HB_ResetWith() does not open a new WITH OBJECT context. As a result, the nesting level of WITH OBJECT and the return value of HB_WithObjectCounter() remain unchanged.

Info

See also:HB_SetWith(), HB_QWith(), HB_WithObjectCounter(), WITH OBJECT
Category: Object functions , xHarbour extensions
Source:vm\hvm.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example shows how to change the current "with" object
// without changing the nesting level of WITH OBJECT

   PROCEDURE Main()
      LOCAL oSavedWith

      WITH OBJECT ErrorNew()
         ? :className()              // result: ERROR
         ? HB_WithObjectCounter()    // result: 1

         oSavedWith := HB_QWith()

         HB_ResetWith( GetNew() )

         ? :className()              // result: GET
         ? HB_WithObjectCounter()    // result: 1

         HB_ResetWith( oSavedWith )

         ? :className()              // result: ERROR
         ? HB_WithObjectCounter()    // result: 1
      END

   RETURN

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