Page 1 of 1
Convert a string to upper case in BASIC?
Posted: Sun Dec 15, 2019 4:09 pm
by presuminged
Can this be done?
Re: Convert a string to upper case in BASIC?
Posted: Sun Dec 15, 2019 5:14 pm
by Ralf
There isn't any ready function like ToUpper to do it, I believe.
You can make it with your own code however. Loop through all characters in the string, check their ASCII value and if it is a lowercase letter change it to uppercase.
Re: Convert a string to upper case in BASIC?
Posted: Sun Dec 15, 2019 5:31 pm
by g0blinish
I bet it needs to improvement:
Code: Select all
10 INPUT ">";A$
11 LET b$=""
20 FOR i=1 TO LEN (a$)
21 LET b=CODE (a$(i))
22 IF b>=97 AND b<=122 THEN LET b=b-32
23 LET b$=b$+CHR$ (b-32)
29 NEXT i
30 PRINT b$
Re: Convert a string to upper case in BASIC?
Posted: Sun Dec 15, 2019 5:51 pm
by jpnz
You could use a function - have a look at this
article
Re: Convert a string to upper case in BASIC?
Posted: Mon Dec 16, 2019 9:52 am
by presuminged
Thanks for the replies!