xHarbour Reference Documentation > Function Reference |
Queries or changes the pass-by-reference mode for several string functions.
CSetRef( [<lNewMode>] ) --> lOldMode
The function returns the previous pass-by-reference mode as a logical value.
The previous pass-by-reference mode is initially set to .F. (false) and can be switched on by passing .T. (true). The following functions recognize the previous pass-by-reference mode:
Functions recognizing CSetRef()
If the pass-by-reference mode is On, these functions operate on the original input string when it is passed by reference, rather than creating a copy of the input string and returning the processed copy as a result. In addition, these functions do not return a character string but a logical value when the pass-by-reference mode is On. The input string passed by reference becomes the return value, thus saving memory on string operations.
See also: | CSetAtMuPa() |
Category: | CT:String manipulation , Character functions |
Source: | ct\ctstr.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates the effect of the pass-by-reference // mode by sorting a character string. PROCEDURE Main LOCAL cString := "xHarbour compiler" LOCAL cInput := cString LOCAL cResult // extra memory for cResult required CSetRef( .F. ) cResult := CharSort( @cInput ) ? Valtype( cResult ) // result: C ? cResult // result: Habceilmooprrrux ? cInput // result: Habceilmooprrrux cInput := cString // no extra memory for cResult required CSetRef( .T. ) cResult := CharSort( @cInput ) ? Valtype( cResult ) // result: L ? cResult // result: .F. ? cInput // result: Habceilmooprrrux RETURN
http://www.xHarbour.com