Difference between revisions of "ASC (statement)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 9: Line 9:
 
{{PageDescription}}
 
{{PageDescription}}
 
* The string expression must have been previously defined and cannot be an empty string("").
 
* The string expression must have been previously defined and cannot be an empty string("").
* Position parameter is optional. If no position is used, the first position is assumed.
+
* The ''position'' parameter is optional. If no position is used, the first position is assumed.
* Position cannot be zero or greater than the string's length [[LEN]] or an [[ERROR Codes|Illegal function error]] will occur.
+
* The ''position'' cannot be zero or greater than the string's length [[LEN]] or an [[ERROR Codes|Illegal function error]] will occur.
* The [[ASCII]] replacement code% value can be any value from 0 to 255.
+
* The [[ASCII]] replacement ''code%'' value can be any [[INTEGER]] value from 0 to 255.
 +
* Some [[ASCII]] control characters will not [[PRINT]] a character or may format the [[SCREEN]]. [[_PRINTSTRING]] can print them graphically.
  
  
Line 38: Line 39:
 
* [[ASC]] {{text|(function)}}
 
* [[ASC]] {{text|(function)}}
 
* [[MID$ (statement)]]
 
* [[MID$ (statement)]]
 +
* [[_PRINTSTRING]]
 
* [[INKEY$]], [[ASCII]]
 
* [[INKEY$]], [[ASCII]]
  
  
 
{{PageNavigation}}
 
{{PageNavigation}}

Revision as of 06:48, 2 October 2011

The ASC statement allows a QB64 program to change a character at any position of a predefined STRING.


Syntax

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


Description

  • The string expression must have been previously defined and cannot be an empty string("").
  • The position parameter is optional. If no position is used, the first position is assumed.
  • The position cannot be zero or greater than the string's length LEN or an Illegal function error will occur.
  • The ASCII replacement code% value can be any INTEGER value from 0 to 255.
  • Some ASCII control characters will not PRINT a character or may format the SCREEN. _PRINTSTRING can print them graphically.


Example: Demonstrates how to change existing text characters one letter at a time.

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$

ABC A C ASC


See also:



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page