Author Topic: Convert String to All Caps ?  (Read 207 times)

jacklward

  • Newbie
  • *
  • Posts: 36
Convert String to All Caps ?
« on: May 27, 2018, 10:06:06 AM »
Any easy way to convert a mixed case string to all uppercase without having to look at each character?

I was hoping for a FORMAT Statement solution.

In the mean time, if anyone else has a similar need, the following works...

   
' Converts Mixed Text to ALL CAPS
   
MixedText$ = "azAZ Now is the time 0123 XYZ"

For Count = 1 to Len(MixedText$) ' asc 97-122 to asc 65-90
      AscValue = Asc(mid$(MixedText$,Count,1))
      If AscValue > 96 and AscValue < 123 then
            UpperText$ = UpperText$ + Chr$(AscValue - 32)
         Else
            UpperText$ = UpperText$ + Chr$(AscValue)
         End If
   Next Count

Message UpperText$
« Last Edit: May 28, 2018, 05:36:02 AM by jacklward »

Bob P

  • Hero Member
  • *****
  • Posts: 1209
    • Era Replica Automobiles
Re: Convert String to All Caps ?
« Reply #1 on: May 27, 2018, 01:15:15 PM »
I couldn't find any appropriate SYS or SYS$ function, but AutoHotkey can do it.

From A Beginner's Guide to Autohotkey:

Changing the Case or How to Capitalize
There are some people who only write in all capital letters. This is especially annoying since many
programs and text editing fields don't offer an easy way to change the case of the text from upper to
lower. (Plus, on the Web all capital letters is considered SHOUTING!) What if you had an easy way to
select text in capitals and instantly convert it to lowercase? Not only that, but what if it worked in almost
all of your word processors, text editors, e-mail program, and Web editing fields? It's relatively simple in
AutoHotkey.
The first step as outlined in the previous chapter is to create an AutoHotkey file (AHK) by right-clicking
on the Windows Desktop and selecting New => AutoHotkey Script. (AutoHotkey needs to be installed on
the computer as explained in the last chapter.) Give the new file a name to help you remember its purpose
such as ChangeCase.ahk. Then right-click on the icon for the new file on the Desktop and select Edit
Script. The new file will open with the default text editor, probably Notepad. You will see the standard
embedded lines mentioned in the last chapter. Next, cut and paste the following line of code into the file:

^u:: ; CTRL+U converts text to upper
Clipboard:= ""
Send, ^c ;copies selected text
ClipWait
StringUpper Clipboard, Clipboard
Send %Clipboard%
Return
^l:: ; CTRL+L converts text to lower
Clipboard:= ""
Send, ^c ;copies selected text
ClipWait
StringLower Clipboard, Clipboard
Send %Clipboard%
Return
+^k:: ; SHIFT+CTRL+K converts text to capitalized
Clipboard:= ""
Send, ^c ;copies selected text
ClipWait
StringUpper Clipboard, Clipboard, T
Send %Clipboard%
Return

Lar

  • Hero Member
  • *****
  • Posts: 2818
Re: Convert String to All Caps ?
« Reply #2 on: May 27, 2018, 01:41:44 PM »

It's actually doable with a macro but its very tedious writing code that deals with text. Someone on the forum may have done it already and may bless you with the code. I actually could do it, if someone was paying me... with a trip to Vegas or Japan included (that's not a solicitation, by the way)

Otherwise there are some fonts that only display upper case, no matter what case you type. Maybe you could search for one that you can live with. Some that I have on my system are "Felix Titling" (my pick, like a sophisticated Arial), "Copperplate" (which is all caps but the real caps are taller than the real lowercase, so if you type in all lowercase it will look even), "Engravers MT" (similar to Times New Roman's caps but not as nice), "Castellar" (too fancy?), "Goudy Stout" (too heavy)... and some others not suitable for CAD.


Lar
« Last Edit: May 27, 2018, 01:46:55 PM by Lar »

jacklward

  • Newbie
  • *
  • Posts: 36
Re: Convert String to All Caps ?
« Reply #3 on: May 27, 2018, 03:09:21 PM »
Thank you for the replies.

I have written hundreds of Autohotkey programs.  I would prefer a solution in BasicCAD.

My macro is getting the string from me (Input statement) and I want to change that input to uppercase.

I think BasicCAD's FORMAT statement may be able to do it but I can't figure out the correct syntax for the fmt$, supposedly it is similar to Sprintf() function in C but that was no help either.

If no one knows how then I can always loop through each character and convert them to uppercase in BasicCAD, doing so is not a problem I just assumed there was an easier solution.

Jack
« Last Edit: May 27, 2018, 03:36:55 PM by jacklward »

jacklward

  • Newbie
  • *
  • Posts: 36
Re: Convert String to All Caps ?
« Reply #4 on: May 28, 2018, 05:38:47 AM »
See original post for non FORMAT Statement SOLUTION .

If anyone comes up with a FORMAT or similar simple solution please post it.

Thank You

Jack