PadChr0 - Pad a string with Chr(0) characters

Top  Previous  Next

Syntax

 

<cRetString> := PadChr0( <cString>, <nPaddedSize> )

 

Parameters

 

<cString>

 

String to be padded with trailing 0-bytes.

 

<nPaddedSize>

 

Requested size for <cRetString>.

 

Return value

 

A string of the length <nPaddedSize>. If <cString> is shorter than <nPaddesSize> it is padded up to <nPaddedSize> with trailing Chr(0)s. If <cString> is longer, it is truncated to a length of <nPaddedSize>.

 

Description

 

PadChr0 pads a given string with trailing Chr(0) characters up to a given length.

 

Classification

 

Core

 

Category

 

Array and String Utility

 

Quick Info

 

Library: cckptcor.lib / cckptcor.dll

 

See also

 

LeftChr0

 

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