LockStringArrayIndexed - Lock an array of string data as indexed array to memory

Top  Previous  Next

Syntax

 

<nAddress> := LockStringArrayIndexed( <aStringData>, [<nType] )

 

Parameters

 

<aStringData>

 

An array (list) containing strings or a string to be committed to memory.

 

<nType>

 

Type of string data to be written to memory. This value can be STRINGTYPE_BINARY, STRINGTYPE_BINARY0, STRINGTYPE_TEXT, STRINGTYPE_UNICODETEXT. Specifying this parameter requests character set conversions while copying the string data. Default is STRINGTYPE_BINARY. Checking the type of the written array data with LockStringType will always return STRINGTYPE_BINARY.

 

Return value

 

The memory address where the array data starts. This is actually the address of the pointer table to the array elements.

 

Description

 

LockStringArrayIndexed allocates a memory block for <aStringData> and writes a pointer array to the array elements and the strings contained in <aStringData> to that block. Necessary character set conversions are applied while the data is being moved if a string type other than STRINGTYPE_BINARY, STRINGTYPE_BINARY0 was specified for <nType>. The strings are terminated in memory by one 0-byte (two 0-bytes for Unicode strings). The pointer array is also terminated with a 0-address. The memory allocated by LockStringArrayIndexed must later on be explicitly released with ReleaseLockString. The string type recorded is always STRINGTYPE_BINARY. To read the data committed to memory use CopyMemoryToStringArrayIndexed.

 

Classification

 

Core

 

Category

 

Pointers and Memory

 

Quick Info        

 

Library: cckptcor.lib / cckptcor.dll

Header: StringTypes.ch

 

See also

 

ReleaseLockString, CopyMemoryToStringArrayIndexed

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

#INCLUDE "StringTypes.ch"

 

FUNCTION Main

 

LOCAL address

 

* Lock an indexed Unicode string array to memory

address := LockStringArrayIndexed( {"Here","we","go"}, STRINGTYPE_UNICODETEXT )

 

* Show the data byte by byte in hex form

? "Data bytes: ",HexString( CopyMemoryToString( address,, LockStringSize(address) ) )

 

* Read the data back into an array

? "Data: ", CopyMemoryToStringArrayIndexed( address, STRINGTYPE_UNICODETEXT )

 

* Free the allocated memory

ReleaseLockString(address)

 

RETURN NIL