Hi,
Looking to convert mixed Upper/lower case characters to Upper case. Not sure where to start. Any help would be appreciated!
Compiler is mikroBasic Pro for PIC32.
Dim TXdata as string[4]
TXdata = "Fred"
How do I make 'Fred' look like 'FRED'?
Thank you!
Converting a String to Upper case.
Re: Converting a String to Upper case.
looking as ascii chart on web, you'll see 'A' = 65 and 'a' = 97.... the difference is 32. which means you can loop through the string until null is reached while checking each character to see if( (char >= 'a') && (char <= 'z') ) if true for current character subtract 32 which happens to be a ' ' character. this will upper case all characters in string but only if they are a lower case character from and including a-z.
Re: Converting a String to Upper case.
Looks good!
Having trouble implementing it, though...
Thank you!
Having trouble implementing it, though...
Thank you!
Re: Converting a String to Upper case.
Struggling with the Mikrobasic statements to implement this function:
if( (char >= 'a') && (char <= 'z') ) if true subtract 32.
Not sure how to subtract a number from a string.
Does anyone have the code for this, or can suggest another way of converting a mixed Upper/lower case string to an uppercase string?
Thank you!
if( (char >= 'a') && (char <= 'z') ) if true subtract 32.
Not sure how to subtract a number from a string.
Does anyone have the code for this, or can suggest another way of converting a mixed Upper/lower case string to an uppercase string?
Thank you!
Re: Converting a String to Upper case.
32 is also the the ascii space character which is ' ', will it let you subtract by ' ' ? sorry i don't know anything about basic
Re: Converting a String to Upper case.
Issue solved:
Code becomes -
for i= 0 to length(textin)
if (textin >= 97) and (textin <= 122) then
textin= textin- 32
end if
next i
brandonb…Thanks again!
Code becomes -
for i= 0 to length(textin)
if (textin >= 97) and (textin <= 122) then
textin= textin- 32
end if
next i
brandonb…Thanks again!
Re: Converting a String to Upper case.
right on, thanks for the updatebrandonb…Thanks again!