Navigation:  thinBasic Modules > Core > String handling >

CSET$

Previous pageReturn to chapter overviewNext page

 

Description

 

Return a string containing a centered (padded) string.

 

Syntax

 

s = CSET$(StringExpression, StrLen [USING PadString])

 

Returns

 

String

 

Parameters

 

Name

Type

Optional

Meaning

StringExpession

String

No

The string expression to format

StrLen

Number

No

Len of the resulting string

PadString

String

Yes

If present, first char of PadString will be used as padding char, otherwise spaces will be used.

 

Remarks

 

Restrictions

 

See also

 

String Handling, LSET$, RSET$,

 

Examples

 

Thanks to Abraxas for the following script example

' Usage of the LSET$ Keyword example

' Usage of the CSET$ Keyword example

' Usage of the RSET$ Keyword example

 

Dim MyOLDString  As String VALUE "HELLO WORLD"

Dim MyLSETString As String

Dim MyCSETString As String

Dim MyRSETString As String

Dim sMsg         As String

 

MyLSETString = LSET$(MyOLDString, Length+10 USING "*"

MyCSETString = CSET$(MyOLDString, Length+10 USING "*"

MyRSETString = RSET$(MyOLDString, Length+10 USING "*")

 

sMSG += "Strings Padded with * " & $CRLF & $CRLF 

sMsg += "Normal " & MyOLDString  & $CRLF & $CRLF

sMsg += "LSET$ "  & MyLSETString & $CRLF & $CRLF

sMsg += "CSET$ "  & MyCSETString & $CRLF & $CRLF

sMsg += "RSET$ "  & MyRSETString & $CRLF & $CRLF

 

MSGBOX 0, sMsg