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.
StrLower() StrUpper() StrTitle()
Re: StrLower() StrUpper() StrTitle()
- @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?
- 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
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: StrLower() StrUpper() StrTitle()
I think the real question would rather be, why have these functions when you can easily do it with Format?.The question remains whether people want StrTitle in AHK v2 (and v1). What do people think?
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.
Re: StrLower() StrUpper() StrTitle()
- 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.
- 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.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: StrLower() StrUpper() StrTitle()
Are you saying that using Format for this is difficult?.AutoHotkey was designed for beginners.
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.The Format version is difficult to remember and awkward to type
What does this have to do with this topic?. No other (talking about AHKv2).Which other core functions would you wish to remove?
Re: StrLower() StrUpper() StrTitle()
can they become methods on a string instead?
Code: Select all
"asd".upper()
"asd".lower()
"asd".title()
"asd".upper().title()
Re: StrLower() StrUpper() StrTitle()
I’d love to see the language move to this. Same with arrays/objects.
Who is online
Users browsing this forum: filipemb and 52 guests