STRING$

<< Click to Display Table of Contents >>

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

STRING$

 

Description

 

Return a string consisting of multiple copies of the specified character.

 

Syntax

 

s = STRING$(Count, Code            )

s = STRING$(Count, StringExpression)

 

Returns

 

String

 

Parameters

 

Name

Type

Optional

Meaning

Count

Numeric

No

Number of copies

Code

Numeric

No

Ascii code (see remarks)

StringExpression

String

No

String char (see remarks)

 

Remarks

 

STRING$ with a numeric argument returns a string of count copies of the character with the ASCII code of code, where code is between 0 and 255, inclusive.

STRING$ with a string argument returns a string of count copies of the first character in StringExpression.

 

Restrictions

 

See also

 

String Handling,

 

Examples

 

Thanks to Abraxas for the following script example

' Usage of the STRING$ Keyword example

 

Dim sStringExpression As String VALUE "THINBASIC"

Dim sSTR              As String

Dim sChar             As String

Dim Counter           As DWORD

Dim sMsg              As String

 

sMsg += "sStringExpression = " & sStringExpression & $CRLF & $CRLF

 

' Take a letter from sStringExpression for the string fill character

For Counter = 1 To Len(sStringExpression)

  sChar = MID$(sStringExpression, Counter, 1)

  sSTR  = String$(Counter, sChar)

  sMsg += "STRING$(" & Counter & ", " & sChar & ") = " & $Tab & sSTR & $CRLF

Next

 

MSGBOX 0, sMsg