-
Notifications
You must be signed in to change notification settings - Fork 9
BASIC String Functions
TYPE: BASIC [String Function
FORMAT: LEFT$(string,integer)
Action: Returns a string comprised of the leftmost integer characters of the string. The integer argument value must be in the range 0 to 255. If the integer is greater than the length of the string, the entire string will be returned. If an integer value of zero is used, then a null string (of zero length) is returned.
Examples:
10 A$ = "AQUARIUS COMPUTERS"
20 B$ = LEFT$(A$,8): PRINT B$
RUN
Prints
AQUARIUS
TYPE: BASIC [String Function
FORMAT: MID$(string,numeric-1[,numeric-2])
Action:
The MID$ function returns a sub-string which is taken from within a larger string argument. The starting position of the sub-string is defined by the numeric-1 argument and the length of the sub-string by the numeric-2 argument. Both of the numeric arguments can have values ranging from 0 to 255.
If the numeric-1 value is greater than the length of the string, or if the numeric-2 value is zero, then MID$ gives a null string value. If the numeric-2 argument is left out, then the BASIC will assume that a length of the rest of the string is to be used. If the source string has fewer characters than numeric-2, from the starting position to the end of the string argument, then the whole rest of the string is used.
Examples:
10 A$="GOOD"
20 B$="MORNING EVENING AFTERNOON"
30 PRINT A$ + MID$(B$,8,8)
Prints
GOOD EVENING
TYPE: BASIC [String Function
FORMAT: RIGHT$ ( string , length )
Action: Returns a sub-string taken from the right-most end of the string argument. The length of the sub-string is defined by the numeric argument which can be any integer in the range of 0 to 255. If the value of the numeric expression is zero, then a null string ("") is returned. If the value you give in the numeric argument is greater than the length of the string then the entire string is returned.
Examples:
10 MSG$="Aquarius+ Computer"
20 PRINT RIGHT$(MSG$,8)
RUN
Prints
Computer
TYPE: plusBASIC v0.22t string function
FORMAT: PAD$( expression , length )
Action: Returns a string contain string padded with spaces to length length.
-
expression is the string to be padded.
- If expression is numeric, it is automatically converted to a string.
- length is an expression that evaluates to an integer in the range -255 through 255.
- If length is positive, spaces are added to the left.
- If string is longer than length, the first length characters are returned.
- If length is negative, spaces are added to the left.
- If string is longer than length, the last length characters are returned.
- If length is
0, an empty string is returned.
Examples:
PAD$("xyz",9)
Returns
"xyz "
PAD$(123,9)
Returns
"123 "
PAD$("xyz",-10)
Returns
" xyz"
PAD$("234",-6)
Returns
" 234"
PAD$("xyz",1)
Returns
"x"
PAD$("xyz",-2)
Returns
"yz"
PAD$("xyz",0)
Returns
""
FORMAT: PAD$( expression , length , char )
Action: As above, but the string is padded with char instead of spaces.
-
char is an expression that evaluates to either a string or an integer in the range 0 through 255.
- If char is an integer, the string is padded with the corresponding ASCII character.
- If char is a string, the first character is used as the pad character.
-
Illegal quantityresults if char is an empty string.
Examples:
PAD$("xyz",9,"!")
Returns
"xyz!!!!!!"
PAD$(123,9,"x")
Returns
"123!!!!!!"
PAD$("xyz",-10,"@")
Returns
"@@@@@@@xyz"
PAD$(456",-6,"0")
Returns
"000456"
PAD$("xyz",5,0)
Returns
"xyz££"
PAD$("xyz",-6,0)
Returns
"£££xyz"
TYPE: plusBASIC v0.21x [String Function
FORMAT: TRIM$ ( string )
Action: Trims white space characters from both ends of string.
- string is the string to be trimmed.
- Whitespace characters are characters with an ASCII value less than or equal to 32 (Space).
Examples:
TRIM$(" 123 ")
Returns string
123
TRIM$(" ")
Returns string with length 0.
FORMAT: TRIM$(string,chars)
Action: As above, but trims the specified characters from each end of the string.
- chars is a string containing a list of characters to be trimmed.
Examples:
TRIM$("@@@123@@@","@")
Returns string
123.
TRIM$("@@@@@@","@")
Returns string with length 0.
TRIM$("#*#abc#*#","*#")
Returns string
abc.
TYPE: plusBASIC v0.21x [String Function
FORMAT: TRIML$ ( string )
Action: As above but trims whitespace characters from the left end of the string.
Examples:
PRINT TRIML$(" 123 ");"x" `
Returns string
123.
TRIML$(" ")
Returns string with length 0.
FORMAT: TRIML$(string,chars)
Action: As above, but trims the specified characters from the left end of the string.
Examples:
TRIML$("@@@123@@@","@")
Returns string
123@@@.
TRIML$("@@@@@@","@")
Returns string with length 0.
TRIML$("#*#abc#*#","*#")
Returns string
abc#*#.
TYPE: plusBASIC v0.21x [String Function
FORMAT: TRIMR$ ( string )
Action: As above but trims whitespace characters from the left end of the string.
Examples:
TRIMR$(" 123 ")
Returns string
123.
TRIMR$(" ")
Returns string with length 0.
FORMAT: TRIMR$(string,chars)
Action: As above, but trims the specified characters from the left end of the string.
Examples:
TRIMR$("@@@123@@@","@")
Returns string
@@@123.
TRIMR$("@@@@@@","@")
Returns string with length 0.
`'' TRIMR$("##abc##","*#") '''
Returns string
#*#abc.
TYPE: plusBASIC string function
FORMAT: STRING$ ( length )
Action: Returns a string of composed of length spaces (ASCII code 32).
- _length _ is an expression that evaluates to an integer.
- Illegal Quantity Error results if length is not in the range 0 through 255.
Examples:
PRINT "<";STRING$(20);">"
Prints
< >
FORMAT: STRING$ ( length , byte )
Action: As above, but the string is composed of the characters with ASCII code byte.
- _byte _ is an expression that evaluates to an integer.
- Illegal Quantity Error results if byte is not in the range 0 through 255.
Examples:
PRINT STRING$(5,64)
Prints
@@@@@
PRINT STRING$(3,'Z')
Prints
ZZZ
FORMAT: STRING$ ( length , string )
Action: As above, but the string is composed of the first character of string.
- Illegal Quantity Error results if string is empty.
Examples:
10 X$=STRING$(10,"-")
20 PRINT X$;"MONTHLY REPORT";X$
Prints ----------MONTHLY REPORT----------
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