STRING$ - QB64 Wiki

STRING$

From QB64 Wiki

Revision as of 19:34, 12 November 2011 by Clippy (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The STRING$ function returns a STRING consisting of a single character repeated a number of times.


Syntax:

result$ = STRING$(count%, {character$ | ASCIIcode%} )


Description:

  • count% is the number of times the character specified by character is repeated.
  • Character is a literal string character, a string variable or an ASCII code number.
  • If count% is negative, an illegal function call error will occur. The count can be zero.
  • If character is a STRING value and its length is zero, an illegal function call error will occur.
  • If more than one string character value is used, the first character will be repeated.
  • A STRING statement can be added to a string value with the + concatenation operator.
  • The function result can also be used to GET and PUT a number of bytes as zero characters: bytes$ = STRING(numbytes, 0)


Code Examples:

Printing 40 asterisks across the screen using an ASCII character value.

PRINT STRING$(40, 42)

****************************************


Using a STRING to specify the repeated character.

text$ = "B" + STRING$(40, "A") + "D" PRINT text$

BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD

Note: The string contatenation + operator MUST be used in STRING variable definitions.


See examples:


See also:



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page