Navigation:  thinBasic Modules > Core > String handling >

STRING$

Previous pageReturn to chapter overviewNext page

 

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

 

 

 

© 2004-2008 thinBasic. All rights reserved. Version 1.7.0.0 Web Site: http://www.thinbasic.com