xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_String2Pointer()

Obtains the pointer for a character string.

Syntax

HB_String2Pointer( <cString> ) --> pPointer

Arguments

<cString>
This is a variable holding the character string to retrieve the pointer for.

Return

The function returns the pointer (memory address) of the passed string as a Poiner value (Valtype()=="P").

Description

The function obtains the memory address of the character string <cString> and returns it as a Pointer value.

Info

See also:C Structure class, HB_Pointer2String()
Category: Pointer functions , xHarbour extensions
Source:rtl\str2ptr.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example converts a string to a pointer, voids the string
// variable, and reads the string back from the pointer.

   PROCEDURE Main
      LOCAL cString := "Hello World"
      LOCAL pString := HB_String2Pointer( cString )
      LOCAL nBytes

      ? Valtype( cString ), cString  // result: C Hello World
      ? Valtype( pString ), pString  // result: P 004b100a

      nBytes  := Len( cString )
      cString := NIL

      ? Valtype( cString ), cString  // result: U NIL
      ? Valtype( pString ), pString  // result: P 004b100a

      cString := HB_Pointer2String( pString, nBytes )

      ? Valtype( cString ), cString  // result: C Hello World
      ? Valtype( pString ), pString  // result: P 004b100a
   RETURN

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