StrLower() StrUpper() StrTitle()

Propose new features and changes
User avatar
DrReflex
Posts: 14
Joined: 25 May 2015, 02:57

StrLower() StrUpper() StrTitle()

28 Jul 2018, 15:07

I know this is an old discussion, but not having these functions is a shame. In version 1.1 StringLower and StringUpper are semantically inconsistent.
Many other programming languages offer inline change of case functions.

StringLower, OutputVar, InputVar [,T] and StringUpper, OutputVar, InputVar [,T] use atypical syntax (i.e. Command, variable, variable rather than the typical AHK syntax of Command, string, string or Command, %variable%, %variable%.

More importantly there are many times where being able to inject a change of case into a conditional statement is very desirable. Rather than programming a function to provide this basic transformation in every script where it is needed, it seems more reasonable to ask that these functions to be included into the programming script.

LowerStr := StrLower(String)
UpperStr := StrUpper(String)
TitleStr := StrTitle(String)

Having these functions will clearly save programming time, improve readability, and make AHK easier for the novice to pick up by avoiding the current semantic inconsistency noted above.
If I were voting, I would deprecate StringLower and StringUpper.
User avatar
Flipeador
Posts: 1019
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Re: StrLower() StrUpper() StrTitle()

28 Jul 2018, 15:20

I would deprecate StringLower and StringUpper and advise users to use Format instead. ;)
Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina SublimeText 3 & AHKv2 My GDI+ Library
User avatar
jeeswg
Posts: 5443
Joined: 19 Dec 2016, 01:58
Location: UK

Re: StrLower() StrUpper() StrTitle()

28 Jul 2018, 16:02

- @DrReflex: I generally agree with what you're saying. Btw AHK v2 has StrUpper and StrLower already. To do title case you add a T parameter.
- You might like this library (perhaps some of the AHK v2 functions will officially make it to AHK v1 at some future point):
commands as functions (AHK v2 functions for AHK v1) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 37&t=29689
- The question remains whether people want StrTitle in AHK v2 (and v1). What do people think?

Code: Select all

vText := "HeLLo"
vUpper := Format("{:U}", vText)
vTitle := Format("{:T}", vText)
vLower := Format("{:L}", vText)
MsgBox, % vUpper "`r`n" vTitle "`r`n" vLower

vText := "HeLLo"
vUpper := StrUpper(vText)
vTitle := StrLower(vText, "T")
vLower := StrLower(vText)
MsgBox, % vUpper "`r`n" vTitle "`r`n" vLower

;AHK v2 functions for AHK v1
StrLower(String, T:="")
{
    local OutputVar
    StringLower OutputVar, String, %T%
    return OutputVar
}
StrUpper(String, T:="")
{
    local OutputVar
    StringUpper OutputVar, String, %T%
    return OutputVar
}
User avatar
Flipeador
Posts: 1019
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Re: StrLower() StrUpper() StrTitle()

28 Jul 2018, 16:09

The question remains whether people want StrTitle in AHK v2 (and v1). What do people think?
I think the real question would rather be, why have these functions when you can easily do it with Format?.
I do not think that satisfying the personal tastes of each user is a good answer. Format already does it in a very simple way.
Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina SublimeText 3 & AHKv2 My GDI+ Library
User avatar
jeeswg
Posts: 5443
Joined: 19 Dec 2016, 01:58
Location: UK

Re: StrLower() StrUpper() StrTitle()

28 Jul 2018, 16:25

- AutoHotkey was designed for beginners. And some of this functionality is similarly straightforward in other programming languages.
- The Format version is difficult to remember and awkward to type, even though I'm familiar with it. (Although I like the Format function and find it useful.)
Format("{:U}", vText)
StrUpper(vText)
- I'm sympathetic to not being too quick to add in new functions (although in this case the functions are just being renamed). Which other core functions would you wish to remove?
- Re. 'personal tastes', anything in a major programming language, or in MS Excel, is a good candidate (although not necessarily a must) for an AutoHotkey function. And these functions fall within that category.
User avatar
Flipeador
Posts: 1019
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Re: StrLower() StrUpper() StrTitle()

28 Jul 2018, 16:48

AutoHotkey was designed for beginners.
Are you saying that using Format for this is difficult?.
The Format version is difficult to remember and awkward to type
I don't find it hard to remember. I'd say it's just a bit awkward to type, but not enough to have a separate function that does exactly the same thing. It could be compared with other commands/functions.
Which other core functions would you wish to remove?
What does this have to do with this topic?. No other (talking about AHKv2).
Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina SublimeText 3 & AHKv2 My GDI+ Library

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 9 guests