LockStringLen - Get the length (number of characters) of a string locked in memory

Top  Previous  Next

Syntax

 

<nLen> := LockStringLen( <nAddress> )

 

Parameters

 

<nAddress>

 

Address of allocated memory block that was returned by LockString or LockNullString.

 

Return value

 

Length of string (number of characters) locked in memory at address <nAddress>. If <nAddress> is not of numeric type, 0 is returned.

 

Description

 

LockStringLen returns the length of the string (number of characters) that was written to memory using LockString or LockNullString. The string length will differ from the number of bytes for Unicode text strings. Use LockStringSize to retrieve the number of bytes.

 

Classification

 

Core

 

Category

 

Pointers and Memory

 

Quick Info

 

Library: cckptcor.lib / cckptcor.dll

 

See also

 

LockString, LockNullString, LockStringSize

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

#INCLUDE "StringTypes.ch"

 

FUNCTION Main

 

LOCAL address

 

* Allocate memory and fill it with "Here"

address := LockString( "Here", STRINGTYPE_UNICODETEXT )

 

* Read the string length, 4 should be the result

? LockStringLen( address )

 

* Release the allocated memory

ReleaseLockString( address )

 

RETURN NIL