LTRIM$

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Core Language > BuiltIn Functions > String functions >

LTRIM$

 

Description

 

Return a copy of a string, with leading characters or strings removed.

 

Syntax

 

s = LTRIM$(MainString [, [ANY] MatchString])

 

Returns

 

String

 

Parameters

 

Name

Type

Optional

Meaning

MainString

String

No

String expression to check

MatchString

String

Yes

If MatchString is not specified, LTRIM$ removes leading spaces. LTRIM$ returns a sub-string of MainString, from the first non-MatchString (or non-space) to the end of the string.  If MatchString (or a space) is not present at the beginning of MainString, all of MainString is returned.

 

If the ANY keyword is included, MatchString specifies a list of single characters to be searched for individually.  A match on any one of these as a leading character will cause the character to be removed from the result.

 

Remarks

 

Restrictions

 

LTRIM$ is case-sensitive.

 

See also

 

String Handling, RTRIM$, TRIM$, TRIMFULL$,

 

Examples

 

Thanks to Abraxas for the following script example

' Usage of the LTRIM$ Keyword example

' Usage of the RTRIM$ Keyword example

' Usage of the TRIM$ Keyword example

' Usage of the TRIMFILL$ Keyword

 

Dim MyOLDString      As String VALUE "HELLO WORLD"

Dim MyOLD2String     As String VALUE " A B C D E F "

Dim MyLTRIMString    As String

Dim MyRTRIMString    As String

Dim MyTRIMString     As String

Dim MyTRIMFULLString As String

Dim sMsg             As String

 

MyLTRIMString    = LTRIM$(MyOLDString, Any "HELLO"

MyRTRIMString    = RTRIM$(MyOLDString, Any "WORLD"

MyTRIMString     = TRIM$(MyOLDString , Any "HEL")

MyTRIMFULLString = TRIMFULL$(MyOLD2String)

 

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

sMsg += "LTRIM$ "    & MyLTRIMString & $CRLF & $CRLF

sMsg += "RTRIM$ "    & MyRTRIMString & $CRLF & $CRLF

sMsg += "TRIM$ "     & MyTRIMString  & $CRLF & $CRLF

sMsg += "TRIMFULL$ " & MyTRIMFULLString & $CRLF & $CRLF ' spaces removed

 

MSGBOX 0, sMsg