-
Notifications
You must be signed in to change notification settings - Fork 9
BASIC Conversion Functions
TYPE: BASIC Conversion Function
FORMAT: ASC ( string )
Action: Returns a number from 0 to 255 corresponding to the ASCII value of the first character in the string.
- string is the string to be evaluated.
- Illegal quantity results if the length of string is zero.
Examples
PRINT ASC("Z")
Prints
90(the ASCII value of "Z")
X = ASC("zebra")
Sets X to 122 (the ASCII value of "z")
J = ASC(J$)
Sets J to the ASCII value of the first character of J$
plusBASIC v0.23h enhancement
FORMAT: ASC ( string , pos )
Action: Returns a number from 0 to 255 corresponding to the ASCII value of the specified character in the string.
- string is the string to be evaluated.
- pos is the position of the character.
- Illegal quantity results if pos is less than one or greater than the length of string.
Examples
PRINT ASC("ABCDE",3)
Prints
67(the ASCII value of "C")
TYPE: plusBASIC string function
FORMAT: ASC$ ( hexstring )
Action: Convert hex_string to an ASCII string.
-
hexstring is a string containing an even number of hexadecimal digits.
- Returns a string of length 0 if the length of hexstring is 0.
- Illegal Quantity results if hexstring contains an odd number of characters or any character is not a hexadecimal digit.
Examples
10 READ H$
20 A$=ASC$(H$)
30 DATA FF
Sets A$ to a ASCII character 255.
PRINT ASC$("30313233")
Prints
0123-- the ascii characters for hex values 30, 31, 32, and 33.
TYPE: plusBASIC Conversion Function
FORMAT: BYTE ( string )
Action: Returns a number from -128 to 127 corresponding to the binary value of the first character in a string.
- string is the string to be evaluated.
- Illegal quantity results if the length of string is zero.
Example:
10 H$="Hello!"
20 A=BYTE(H$)
30 PRINT A
Sets A to 72, the signed integer value of the first character in
Hello!(H), then prints it.
FORMAT: BYTE ( string , pos )
Action: Returns a number from -128 to 127 corresponding to the binary value of the specified character in the string.
- string is the string to be evaluated.
- pos is the position of the character.
- Illegal quantity results if pos is less than one or greater than the length of string.
Example:
10 Z$="Amazing!"
20 Q=BYTE(Z$,4)
30 PRINT Q
Sets Q to 112, the signed integer value of the fourth character in
Amazing!(z), then prints it.
TYPE: BASIC String Function
FORMAT: CHR$ (number)
Action: Converts an ASCII code to a character string.
- The string will contain a single character with the ASCII value number,
- Illegal Quantity error results if number is not in the range 0 through 255.
Note: See plusBASIC ASCII Table for a list of characters and their codes.
Example:
10 PRINT CHR$(65) : REM 65 = UPPER CASE A
20 A$=CHR$(13) : REM 13 = RETURN KEY
50 A=ASC(A$) : A$ = CHR$(A) : REM CONVERTS TO ASCII CODE AND BACK
plusBASIC v??? enhancement
number may be in the range -255 to 255.
- Numbers less than 0 are treated as twos-complement, resulting in an ASCII value of 256 + number.
TYPE: USB BASIC Conversion Function
FORMAT: DEC ( string )
Action: Returns a number from 0 to 65535 corresponding to the hexadecimal digits at the beginning of a string.
- string is the string to be evaluated.
- Value of 0 will be returned if the first character is not a valid hexadecimal digit: 0-9, A-F/a-f .
- Hexadecimal digits must be contiguous from the beginning of the string. Any non-hexadecimal digit will "end" the evaluation.
- Overflow error results if the hexadecimal digits evaluate to a value greater than 65535 (usually because there are five or more valid hexadecimal characters at the beginning of the string).
Examples:
10 H$ = "a0b1jzqt"
20 A = DEC(H$)
30 PRINT A
Sets A to 41137, the integer value of the hexadecimal equivalent of the first four characters in
a0b1jzqt(#A0B1), then prints it.
PRINT DEC("fffff")
Returns
Overflow errorbecause all five characters at the beginning of the string are valid hexadecimal digits (#FFFFF), but their value exceeds 65535.
TYPE: USB BASIC string function
FORMAT: HEX$ ( number )
Action: Returns string containing number in two-byte hexadecimal format.
- number is an expression that reduces to in integer in the range -32768 to 32767.
Examples
PRINT HEX$(1)
Prints "01"
10 PRINT HEX$(PEEK(12288))
Prints the HEX value of the border char (usually "20", SPACE character)
plusBASIC enhancement
- address can be in the range -65535 and 65535 ($0000 to $FFFF).
TYPE: plusBASIC string function
FORMAT: HEX$ ( string )
Action: Returns string containing a list of two-character hexadecimal numbers corresponding to the characters in string.
- string is an expression that evaluates to a string no more than 127 characters long.
- The returned string will be twice as long as the argument string.
Examples:
PRINT HEX$("ABC")
Prints
414243
10 PRINT HEX$(STR$(10))
Prints
203132
TYPE: BASIC Conversion Function
FORMAT: INT ( string )
Action: Returns a number from -32768 to 32767 corresponding to the binary value of the first two bytes of a string expression.
- string is the string to be evaluated.
- Illegal quantity results if the length of string is less than 2.
FORMAT: INT ( string , pos )
Action: Returns a number from -32768 to 32767 corresponding to the binary value of the first two bytes starting at character pos of a string.
- string is the string to be evaluated.
- Illegal quantity results if the length of string is less than or equal to pos.
TYPE: BASIC Conversion Function
FORMAT: LWR (number)
Action: Returns the ASCII code of the lowercase equivalent of the specified character.
- number is an expression evaluating to the ASCII code of the character to be converted.
- Illegal Quantity error results if number is not in the range -256 through 255.
- Values in the range -256 through -1 are evaluated as 0 through 255, respectively.
- ASCII codes 65 through 90 (
A-Z) are converted to 97 through 122 (a-z), respectively,- No other characters are changed.
FORMAT: LWR (string)
Action: Returns the ASCII code of the lowercase equivalent of the first character of the specified string.
- string is a string expression containing the character to be converted.
- Illegal Quantity error results if string has a length of 0.
- ASCII codes 65 through 90 (
A-Z) are converted to 97 through 122 (a-z), respectively,- No other characters are changed.
TYPE: BASIC String Function
FORMAT: LWR$ (number)
Action: Returns a one character string containing the lowercase equivalent of the specified character.
- number is an expression evaluating to the ASCII code of the character to be converted.
- Illegal Quantity error results if number is not in the range -256 through 255.
- Values in the range -256 through -1 are evaluated as 0 through 255, respectively.
- ASCII codes 65 through 90 (
A-Z) are converted to 97 through 122 (a-z), respectively,- No other characters are changed.
FORMAT: LWR$ (string)
Action: Returns a string in which all the uppercase characters or replaced with their lowercase equivalents.
- string is a string expression containing the string to be converted.
- ASCII codes 65 through 90 (
A-Z) are converted to 97 through 122 (a-z), respectively,- No other characters are changed.
TYPE: BASIC String Function
FORMAT: STR$(numeric)
Action:
STR$ gives you the string representation of the numeric value of the argument. When the STR$ value is converted to each variable
represented in the numeric argument, any number shown is followed by a space and, if it's positive, it is also preceded by a space.
EXAMPLES of STR$ Function:
100 FLT = 1.5E4: ALPHA$ = STR$(FLT)
110 PRINT FLT, ALPHA$
15000 15000
TYPE: BASIC Conversion Function
FORMAT: UPR (number)
Action: Returns the ASCII code of the uppercase equivalent of the specified character.
- number is an expression evaluating to the ASCII code of the character to be converted.
- Illegal Quantity error results if number is not in the range -256 through 255.
- Values in the range -256 through -1 are evaluated as 0 through 255, respectively.
- ASCII codes 97 through 122 (
a-z) are converted to 65 through 90 (A-Z), respectively,- No other characters are changed.
FORMAT: UPR (string)
Action: Returns the ASCII code of the uppercase equivalent of the first character of the specified string.
- string is a string expression containing the character to be converted.
- Illegal Quantity error results if string has a length of 0.
- ASCII codes 97 through 122 (
a-z) are converted to 65 through 90 (A-Z), respectively,- No other characters are changed.
TYPE: BASIC String Function
FORMAT: UPR$ (number)
Action: Returns a one character string containing the uppercase equivalent of the specified character.
- number is an expression evaluating to the ASCII code of the character to be converted.
- Illegal Quantity error results if number is not in the range -256 through 255.
- Values in the range -256 through -1 are evaluated as 0 through 255, respectively.
- ASCII codes 97 through 122 (
a-z) are converted to 65 through 90 (A-Z), respectively,- No other characters are changed.
FORMAT: UPR$ (string)
Action: Returns a string in which all the uppercase characters or replaced with their lowercase equivalents.
- string is a string expression containing the string to be converted.
- ASCII codes 97 through 122 (
a-z) are converted to 65 through 90 (A-Z), respectively,- No other characters are changed.
TYPE: BASIC Conversion Function
FORMAT: VAL(string)
Action:
Returns a numeric value representing the data in the string argument. If the first non-blank character of the string is not a plus sign (+), minus sign (-), or a digit the value returned is zero. String conversion is finished when the end of the string or any non-numeric character is found (except decimal point or exponential e).
EXAMPLE of VAL Function:
10 INPUT#1, NAM$, ZIP$
20 IF VAL(ZIP$) < 19400 OR VAL(ZIP$) > 96699 THEN PRINT NAM$ TAB(25) "GREATER PHILADELPHIA"
TYPE: BASIC ***
TYPE: BASIC Conversion Function
FORMAT: WORD ( string )
Action: Returns a number from 0 to 65535 corresponding to the binary value of the first two bytes of a string expression.
- string is the string to be evaluated.
- Illegal quantity results if the length of string is less than 2.
FORMAT: WORD ( string , pos )
Action: Returns a number from 0 to 65535 corresponding to the binary value of the first two bytes starting at character pos of a string.
- string is the string to be evaluated.
- Illegal quantity results if the length of string is less than or equal to pos.
Function
FORMAT: WORD ( string )
Action: Returns a number from 0 to 65535 corresponding to the binary value of the first two bytes of a string expression.
- string is the string to be evaluated.
- Illegal quantity results if the length of string is less than 2.
FORMAT: WORD ( string , pos )
Action: Returns a number from 0 to 65535 corresponding to the binary value of the first two bytes starting at character pos of a string.
- string is the string to be evaluated.
- Illegal quantity results if the length of string is less than or equal to pos.
FORMAT: WORD$ (number)
Action: Converts an integer to a binary character string.
- The string will contain two characters representing the binary value number,
- Illegal Quantity error results if number is not in the range -65535 through 65535.
- Numbers less than 0 are treated as twos-complement, resulting in binary value of 65536 + number.
To Search for pages in the wiki, press Pages above and type a search term in the "Find a page..." box. Results will update beneath automatically.
- Aquarius+ User Guide
- Quick Start
- Hardware
- Software
-
- plusBASIC QuickRef
- plusBASIC Programmer's Reference Guide
- plusBASIC Tutorials
- [plusBASIC Statement and Function Types
- plusBASIC Error Messages
- plusBASIC ASCII Table
- plusBASIC Glossary of Terms
- plusBASIC Optimization Examples
-
Other Development Resources