ASC (statement)

From QB64 Wiki
Revision as of 00:20, 18 July 2017 by imported>Odin (→‎Details)
Jump to navigation Jump to search

The ASC statement is used to change a character in a string variable into the specified ASCII code.

Syntax

ASC(stringVariable$[, position%]) = code%

Example

<source lang="qbasic">

a$ = "YZC"
ASC(a$) = 65                 ' CHR$(65) = "A"
ASC(a$, 2) = 66              ' CHR$(66) = "B"
PRINT a$ 'ABC
ASC(a$, 2) = 0               ' CHR$(0) = " " 
PRINT a$
ASC(a$, 2) = ASC("S")        ' get code value from ASC function
PRINT a$

</source>

Output:

 ABC
 A C
 ASC

Details

  • If position% isn't passed, ASC changes the leftmost character.