Difference between revisions of "ASC (statement)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Cyperium
Line 1: Line 1:
The '''ASC''' statement allows a '''QB64''' program to change a character at any position of a predefined {{KW|STRING}}.
+
The {{KW|ASC (statement)|ASC}} statement allows a '''QB64''' program to change a character at any position of a predefined {{KW|STRING}}.
  
  
  
+
{{PageSyntax}}
''Syntax:'' ASC(string_expression$[, position%]) = code%
+
:<code>{{KW|ASC (statement)|ASC}}({{Parameter|string_expression$}}[, {{Parameter|position%}}]) = {{Parameter|code%}}</code>
  
  
 +
{{PageDescription}}
 
* The string expression must be predefined.
 
* The string expression must be predefined.
 
* Position parameter is optional. If no position is used, the first position is assumed.
 
* Position parameter is optional. If no position is used, the first position is assumed.
Line 12: Line 13:
 
* The {{KW|ASCII}} code% value can be any value from 0 to 255.
 
* The {{KW|ASCII}} code% value can be any value from 0 to 255.
  
 +
 +
{{PageExamples}}
  
 
''Example:''
 
''Example:''
 
 
{{CodeStart}}
 
{{CodeStart}}
 
  a$ = "YZC"
 
  a$ = "YZC"
  ASC(a$) = 65
+
  {{KW|ASC (statement)|ASC}}(a$) = 65
  ASC(a$, 2) = 66
+
  {{KW|ASC (statement)|ASC}}(a$, 2) = 66
  PRINT a$ 'ABC
+
  {{KW|PRINT}} a$ 'ABC
  
  ASC(a$, 2) = 0
+
  {{KW|ASC (statement)|ASC}}(a$, 2) = 0
  PRINT a$
+
  {{KW|PRINT}} a$
 
{{CodeEnd}}
 
{{CodeEnd}}
  

Revision as of 00:30, 21 June 2010

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 be predefined.
  • 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 illegal function error will occur.
  • The ASCII code% value can be any value from 0 to 255.


Examples

Example:

a$ = "YZC" ASC(a$) = 65 ASC(a$, 2) = 66 PRINT a$ 'ABC ASC(a$, 2) = 0 PRINT a$

ABC A C


See also:

ASC (function), ASCII




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