-
Notifications
You must be signed in to change notification settings - Fork 122
String manipulation module
Wang Renxin edited this page May 31, 2022
·
3 revisions
It is always more convenient to manipulate strings in BASIC than in other programming languages. It's possible to implement more string functions with already built-in ones in MY-BASIC.
The LCASE
and UCASE
functions in MY-BASIC:
def lcase(c)
s = ""
for i = 0 to len(c) - 1
d = mid(c, i, 1)
if d >= "A" and d <= "Z" then
s = s + chr(asc(d) + (asc("a") - asc("A")))
else
s = s + d
endif
next
return s
enddef
def ucase(c)
s = ""
for i = 0 to len(c) - 1
d = mid(c, i, 1)
if d >= "a" and d <= "z" then
s = s + chr(asc(d) + (asc("A") - asc("a")))
else
s = s + d
endif
next
return s
enddef
Use it as follow:
print lcase("Hello");
print ucase("Hello");
- Principles
- Coding
- Data types
- Standalone shell
- Integration
- Customization
- More scripting API
- FAQ