📄 strings.bas
字号:
'-------------------------------------------------
' (c) 1997-2000 MCS Electronics
' STRINGS.BAS
'-------------------------------------------------
$large
$ramstart = &H8000 'address decoder enables RAM chip at this address
$ramsize = &H1000 'I have only 4KB RAM chip
Dim S As Xram String * 50 'dimension string
Dim Z As Xram String * 20 'note that the length must be specified
Dim A As Xram Word
Dim St As Byte
A = 1000
S = "Hello world" 'assign a constant to a string
Print S 'show it
Z = "!z" 'assign string
Print Z
S = Z + " add this too " + Str(a) + Left(s , 4)'concatenate a few strings
Print S
S = "Test"
S = Right(s , 2) : Print S 'return rightportion of string
S = "40000"
A = Val(s) 'convert string to integer
Print A
S = "1FFF"
A = Hexval(s) 'convert hexadecimal string
Print A
S = Hex(a) 'convert back
Print S
A = A + 1 'add 1 to it
S = Str(a) 'convert integer to string
Print S
S = "A"
A = Asc(s) 'get ASCII value
Print A
S = ""
S = Chr(a) 'convert ascii to string
Print S
A = Len(s) 'get length of string
Print A
S = "This is a test"
Z = Left(s , 4) : Print Z 'return left part of string
Z = Right(s , 4) : Print Z 'return right part of string
St = 6
Z = Mid(s , St , 2) : Print Z 'return mid of string
Z = Mid(s , St ) : Print Z 'no length specified
Z = "12345"
Mid(s , 1 , 2) = Z 'change part of string
Print S
Mid(s , 1) = Z
Print S
Z = String(10 , 65) 'make a string with a length of 10 and use character A
Print Z
Z = Space(5) : Print "{" ; Z ; "}" 'make a string with spaces
Input "Name " , S 'ask for string
Print "Hello " ; S 'print it
Restore Company 'restore label with data
Read S : Print S 'read & print
Read S : Print S 'again
If "abc" <> "ABC" Then 'compare constants
Print "Not Equal"
End If
Do
Input "String 1" , S 'ask for string
Input "String 2" , Z 'agian
If S <> Z Then 'compare strings
Print "<>"
Elseif S = Z Then
Print "="
End If
Loop Until S = Z
S = "This is a case TEST"
Z = Lcase(s) : Print Z 'convert to lower case
Z = Ucase(s) : Print Z 'convert to upper case
End
Company: 'company data
Data "MCS" , "Electronics"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -