Convert a string to upper case in BASIC?
- presuminged
- Drutt
- Posts: 11
- Joined: Fri Dec 13, 2019 10:54 am
- Location: Leeds
- Contact:
Convert a string to upper case in BASIC?
Can this be done?
Re: Convert a string to upper case in BASIC?
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.
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?
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$
- jpnz
- Manic Miner
- Posts: 319
- Joined: Tue Nov 14, 2017 4:07 pm
- Location: Hamilt[r]on - City Of The Future - NZ
Re: Convert a string to upper case in BASIC?
You could use a function - have a look at this article
- presuminged
- Drutt
- Posts: 11
- Joined: Fri Dec 13, 2019 10:54 am
- Location: Leeds
- Contact:
Re: Convert a string to upper case in BASIC?
Thanks for the replies!