STRING$: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
The | The [[STRING$]] function returns a [[STRING]] consisting of a single character repeated a number of times. | ||
Line 7: | Line 7: | ||
{{PageDescription}} | {{PageDescription}} | ||
* {{Parameter|count&}} is the number of times the character specified by {{Parameter|character}} is repeated. | * {{Parameter|count&}} is the number of times the character specified by {{Parameter|character}} is repeated. | ||
* Character is a literal string character, a string variable or an [[ASCII]] code number. | * Character is a literal string character, a string variable or an [[ASCII]] code number. | ||
Line 27: | Line 26: | ||
{{OutputStart}}**************************************** | {{OutputStart}}**************************************** | ||
{{OutputEnd}} | {{OutputEnd}} | ||
:Using a [[STRING]] to specify the repeated character. | :Using a [[STRING]] to specify the repeated character. | ||
Line 36: | Line 34: | ||
{{OutputEnd}} | {{OutputEnd}} | ||
=== More Examples === | |||
* [[SaveImage SUB]] | |||
* [[ | |||
* [[SaveIcon32]] | * [[SaveIcon32]] | ||
Latest revision as of 20:06, 5 January 2024
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)
Differences between QB64 and QB 4.5:
- QB64 can use LONG values for a count up to 2,147,483,647 while QB 4.5 could only use INTEGER values up to 32,767.
Examples
- Printing 40 asterisks across the screen using an ASCII character code instead of CHR$(42).
PRINT STRING$(40, 42) |
**************************************** |
- Using a STRING to specify the repeated character.
text$ = "B" + STRING$(40, "A") + "D" PRINT text$ |
BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD |
More Examples
See also