HTBasic Help
×
Menu
Index

String Functions and Conversions

 
The following table assumes A$="HOTDOG".
                                         
Operator
Meaning
Example
Result
&
Concatenation
"HOT"&"DOG"        
"HOTDOG"
[s]
Sub-string, start
A$[4]
"DOG"
[s,e]
Sub-string, start, end
A$[1,3]
"HOT"
[s;l]
Sub-string, start, length
A$[2;4]
"OTDO"
COMMAND$
Command line
COMMAND$
"-O -Z 2"
CVT$
Converts alphabets
CVT$(X$,Y$)
 
ENVIRON$
Environment variable
ENVIRON$("PATH")
"C:\;C:\WINDOWS"
FBYTE
Test for First byte
FBYTE(X$)
0 or 1
LEN
Present length
LEN("AB")
2
LWC$
Lowercase
LWC$("AB")
"ab"
MAXLEN
Dimensioned length
MAXLEN(A$)
18
POS
Position of a sub-string
POS("AB","B")
2
REV$
Reverse
REV$("AB")
"BA"
RPT$
Repeat
RPT$("AB",3)
"ABABAB"
SBYTE
Test for Second byte
SBYTE(X$)
0 or 1
TRIM$
Trim lead/trailing space
TRIM$(" A B ")
"A B"
UPC$
Uppercase
UPC$("ab")
"AB"
 
A substring defines a portion of a string variable or string array element. This capability replaces the RIGHT$, LEFT$, MID$, REP$, and SEG$ functions of other Basics. A sub-string is selected by specifying a starting position within the string value, and optionally, either the length of the sub-string or the ending position within the string value. If only the starting position is specified, the rest of the string value from that point on is used for the sub-string. String positions are one-based, i.e., the first character of a string is in position one.
 
Numeric/String conversions can operate either on ASCII character values (i.e. CHR$(65)) or string representations of numbers (i.e. "65").
 
Operator
Meaning
Example
Result
CINT
Real to integer
CINT(16.0)
16
CMPLX
Real/integer to complex        
CMPLX(2,1)
2+i
CHR$
Numeric to ASCII string
CHR$(65)
"A"
DVAL
Base N to base 10 (32 bit)
DVAL("A",16)
10
DVAL$
Base 10 to base N (32 bit)
DVAL$(11,16)
"B"
&H
Hexadecimal constant        
&H10
16
IVAL
Base N to base 10 (16 bit)
IVAL("A",16)
10
IVAL$
Base 10 to base N (16 bit)
IVAL$(11,16)
"B"
NUM
ASCII character to numeric
NUM("A")
65
&O
Octal constant        
&O20
16
REAL
Integer/complex to real
REAL(16)
16.0
VAL
String to numeric
VAL("65")
65
VAL$
Numeric to string
VAL$(65)
"65"