MC-Basic:ASC

From SoftMC-Wiki
Revision as of 07:24, 17 July 2014 by Nigeller (talk | contribs) (added cross reference)
Jump to: navigation, search

ASC returns an ASCII character value from within an ASCII-8 string, and the Unicode value from within a UTF-8 string.

<return value>: corresponding ASCII character code from a specified  character in an ASCII-8 <string>, or to the Unicode value of a specified  symbol in a UTF-8 <string>.

<string>: string expression from which the character is to be picked. If the sting is empty, the function returns the value 0.

<index>: optional real value defining the position in <string> of the ASCII-8 character or UTF-8 symbol to select. The first ASCII-8 character or UTF-8 symbol of the string is selected if the index is omitted or has a value of 0.

Syntax

?ASC(<string>{,<Index>})

Availability

All versions. Available for UTF-8 string since version 4.5.10

Type

<return value>: Double

<string>: String

<index>: Long

Range

<return value>: 0 to 127 for an ASCII-8 <string>, 0 to MAXLONG for a UTF-8 <string>

<string>: String

<index>: 0 to MaxLong

Scope

Configuration, Task or Terminal

Limitations

Read only

Examples

--> ?ASC("example",3)

9.700000000000000e+01              ‘returns the ASCII code for the letter "a"

--> ?ASC("example")

1.010000000000000e+02              ‘returns the ASCII code for the letter "e"

Common Shared UTF8Str as String of UTF8

UTF8Str = UTF$(196) + UTF$(197) + UTF$(198)

?ASC(UTF8str,2)

1.970000000000000e+02

See Also