Difference between revisions of "ASC (statement)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Odin
imported>Odin
Line 26: Line 26:
  
 
== Details ==
 
== Details ==
* If position% isn't passed, '''ASC''' changes the left-most character.
+
* If position% isn't passed, '''ASC''' changes the leftmost character.

Revision as of 00:20, 18 July 2017

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.