LeftChr0 - Cut off padding characters from a C string

Top  Previous  Next

Syntax

 

<cRetString> := LeftChr0( <cString> )

 

Parameters

 

<cString>

 

String to be scanned for Chr(0). The part left of Chr(0) is returned.

 

Return value

 

The left part of <cString> up to (not including) the first Chr(0) found.

 

Description

 

LeftChr0 returns the "valid" part of a C text string padded with trailing Chr(0) characters. If no Chr(0) character is found, the whole string is returned.

 

Classification

 

Core

 

Category

 

Array and String Utility

 

Quick Info

 

Library: cckptcor.lib / cckptcor.dll

 

See also

 

PadChr0

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

 

FUNCTION Main

 

LOCAL string,netString

 

* Pad a string with trailing 0-bytes to a length of 10 characters

string := PadChr0("Cockpit",10)

 

* Display the result in hex

? HexString(string)

 

* Cut out the net string

netString := LeftChr0(string)

 

* Display in hex

? HexString(netString)

 

RETURN NIL