Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing case of a string
Hi Gintaras,

Nice easy one (even though I cant see a straight answer anywhere, If i have a simple string, how do i change it from "quick macros" to "QUICK MACROS"?

i.e changing everything to uppercase whether they were originally or not.
Macro Macro2
Select All      Help
str sa="abc"
int i
for i 0 sa.len ;; Iterate through each letter, first 'a' then 'b' then 'c', but now we iterate trough each corresponding character code (QM HELP > chapter 'character codes')
,sa[i]=toupper(sa[i]) ;; Current letter in character code format transformed to UPPERCASE.
out sa ;; each letter from string 'sa' has been transformed to uppercase,  output should be: 'ABC'
;; you can change 'toupper' to 'tolower' to convert to lowercase

;; ------ INVERT CASE
;; If you understand above code then you should be able to figure out below code
str sb="xYz"
for i 0 sb.len
out sb ;; should output 'XyZ'

Forum Jump:

Users browsing this thread: 1 Guest(s)