tmsandeep Posted January 20, 2015 Share Posted January 20, 2015 How I can convert first letter in string to small letter Like I got string from Local $str = ClipGet(); Now how I can convert first letter alone to small letter. Link to comment Share on other sites More sharing options...
kylomas Posted January 20, 2015 Share Posted January 20, 2015 one way to do it... local $s = 'What' $s = stringlower(stringleft($s,1)) & stringright($s,stringlen($s)-1) ConsoleWrite($s & @CRLF) kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Malkey Posted January 20, 2015 Share Posted January 20, 2015 A similar way to do it. Local $str = ClipGet() $str = StringLower(StringLeft($str, 1)) & StringMid($str, 2) ConsoleWrite($str & @LF) Link to comment Share on other sites More sharing options...
kylomas Posted January 20, 2015 Share Posted January 20, 2015 yes, better way...I forgot that StringMid defaults to the rest of the string for the 3RD parm... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
tmsandeep Posted January 20, 2015 Author Share Posted January 20, 2015 Thank you folks, it is working great. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 20, 2015 Moderators Share Posted January 20, 2015 Another way:StringLower(StringLeft($sString, 1)) & StringTrimLeft($sString, 1) And another:StringRegExpReplace($sString, "(.)(.*?)$", StringLower(StringLeft($sString, 1)) & "$2") And another:StringLower(StringSplit($sString, "", 2)[0]) & StringTrimLeft($sString, 1) I could probably do this all day. TheSaint and jdelaney 2 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
jguinch Posted January 20, 2015 Share Posted January 20, 2015 StringRegExpReplace($string, "^.", StringLower( StringLeft($string, 1) ) ) StringReplace($string, StringLeft($string, 1) , StringLower( StringLeft($string, 1) ), 1 ) .... all day Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
kylomas Posted January 20, 2015 Share Posted January 20, 2015 Ha! Bet you guys can't come up with a bitwise way of doing it...? Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 20, 2015 Moderators Share Posted January 20, 2015 StringLower(StringRegExp($sString, "^.",1)[0]) & StringTrimLeft($sString, 1) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kylomas Posted January 20, 2015 Share Posted January 20, 2015 (edited) @SmOke_N - I hope that is not in response to me... edit: Was thinking more of a way to use a bitwise operator to add 32 ( or whatever the offset is) to the 1ST byte. Edited January 20, 2015 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 20, 2015 Moderators Share Posted January 20, 2015 (edited) @kylomas Global $gsOut = ((StringIsLower(StringLeft($sString, 1))) ? $sString : Chr(BitXOR(Asc(StringLeft($sString, 1)), 32)) & StringTrimLeft($sString, 1)) Edit: Or: Global $gsOut = ((StringIsLower(StringLeft($sString, 1))) ? $sString : Chr(BitXOR(StringToASCIIArray($sString)[0], 32)) & StringTrimLeft($sString, 1)) Edited January 20, 2015 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kylomas Posted January 20, 2015 Share Posted January 20, 2015 @SmOke_N - WOW, not going to mention that I've been fruitlessly jag'in around with this, on and off, since the thread started. Thanks... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kaesereibe Posted January 21, 2015 Share Posted January 21, 2015 or with MSDN CharLowerBuff function with cchLength = 1 BIN 2 DEC | ConvertTemp | DEC 2 BIN | GetWeekday | HEX 2 RGB | INT 2 HEX | QueryPerformance Link to comment Share on other sites More sharing options...
Malkey Posted January 21, 2015 Share Posted January 21, 2015 (edited) This is using the regular expression unicode character property for lower case, "p{Ll}", to check if the first character is lower case. Ref. from here. Local $sString = "Local $sString" Global $gsOut = StringRegExp($sString, "^\p{Ll}") ? $sString : (Chr(Asc(StringLeft($sString, 1)) + 32) & StringMid($sString, 2)) ConsoleWrite($gsOut & @LF) Edited January 21, 2015 by Malkey Link to comment Share on other sites More sharing options...
kaesereibe Posted January 21, 2015 Share Posted January 21, 2015 (edited) Here is an example with CharLowerBuff$string = "UPPER_TO_LOWER" $length = 1 Func _CharLowerBuff($string, $length) $ret = DllCall("user32.dll", "DWORD", "CharLowerBuff", "str", $string, "DWORD", $length) Return $ret[1] EndFunc ;==> _CharLowerBuff MsgBox(0, "_CharLowerBuff()", _CharLowerBuff($string, $length)) ; ==> uPPER_TO_LOWERor$string = "UPPER_TO_LOWER" $length = 1 $ret = DllCall("user32.dll", "DWORD", "CharLowerBuff", "str", $string, "DWORD", $length) MsgBox(0, "CharLowerBuff()", $ret[1]) ; ==> uPPER_TO_LOWER Edited January 21, 2015 by kaesereibe BIN 2 DEC | ConvertTemp | DEC 2 BIN | GetWeekday | HEX 2 RGB | INT 2 HEX | QueryPerformance Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 21, 2015 Moderators Share Posted January 21, 2015 Or MsgBox(0, "CharLowerBuff()", DllCall("user32.dll", "DWORD", "CharLowerBuff", "str", "UPPER_TO_LOWER", "DWORD", 1)[1]) ; ==> uPPER_TO_LOWER Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
BrewManNH Posted January 21, 2015 Share Posted January 21, 2015 A DLL call seems a LITTLE bit over the top just to make a letter lower cased. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
kaesereibe Posted January 21, 2015 Share Posted January 21, 2015 (edited) Thx for hint SmOke_NWhy not?Isn't AutoIt Function StringLower the same like MSDN CharLower function? Edited January 21, 2015 by kaesereibe BIN 2 DEC | ConvertTemp | DEC 2 BIN | GetWeekday | HEX 2 RGB | INT 2 HEX | QueryPerformance Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 21, 2015 Moderators Share Posted January 21, 2015 @BrewManNH... everyone is just playing around after the first few working examples in the post. But I'd prefer to use the DLL call myself to be honest (if it were wrapped). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
BrewManNH Posted January 21, 2015 Share Posted January 21, 2015 Yeah, but it's one command built into the language, and we let AutoIt worry about the implementation of it. I personally don't care HOW it's done I just want to get it done. I want a quarter inch hole, not a quarter inch drill. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now