sd333221 Posted December 5, 2005 Share Posted December 5, 2005 Hi, I need to get the first letter of for exemple "$letter" I want to split it in 10 parts to make it like this: Letter A-D: Call "Function blabla" Letter E-G: Call "Function blabla" Letter H-K: Call "Function blabla" .... Thank you Cool board, always fast help Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 5, 2005 Moderators Share Posted December 5, 2005 Man... That makes no sense... 10 parts x's 4 letters = 40 Letters? What have you tried? What does an example look like in your script that you would get? What would the end result be? 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...
sd333221 Posted December 5, 2005 Author Share Posted December 5, 2005 No, I mean I have 10 different encryption funtions. To make it harder to generate a keygen, I want my Program to check the first letter of the username and choose a encryption function. Did you understand that? =) Link to comment Share on other sites More sharing options...
themax90 Posted December 5, 2005 Share Posted December 5, 2005 $Functions = StringSplit("Function blablaa", " ") $Functions = StringLeft($Functions[$Functions[0]], 1) Perhaps? Link to comment Share on other sites More sharing options...
GaryFrost Posted December 5, 2005 Share Posted December 5, 2005 (edited) $letter = "gah" $s_letter = StringMid(StringUpper($letter),1,1) Select Case $s_letter = 'A' Or $s_letter = 'B' Or $s_letter = 'C' Or $s_letter = 'D' MsgBox(0,"1st case",$s_letter) Case $s_letter = 'E' Or $s_letter = 'F' Or $s_letter = 'G' MsgBox(0,"2nd case",$s_letter) Case $s_letter = 'H' Or $s_letter = 'I' Or $s_letter = 'J' Or $s_letter = 'K' MsgBox(0,"3rd case",$s_letter) EndSelect Edited December 5, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
sd333221 Posted December 5, 2005 Author Share Posted December 5, 2005 $letter = "gah" $a_letter = StringMid(StringUpper($letter),1,1) Select Case $a_letters[$x] = 'A' Or $a_letters[$x] = 'B' Or $a_letters[$x] = 'C' Or $a_letters[$x] = 'D' MsgBox(0,"1st case",$a_letters[$x]) Case $a_letters[$x] = 'E' Or $a_letters[$x] = 'F' Or $a_letters[$x] = 'G' MsgBox(0,"2nd case",$a_letters[$x]) Case $a_letters[$x] = 'H' Or $a_letters[$x] = 'I' Or $a_letters[$x] = 'J' Or $a_letters[$x] = 'K' MsgBox(0,"3rd case",$a_letters[$x]) EndSelectHmm could you explain what this is doing please? =) thank you for your help Link to comment Share on other sites More sharing options...
GaryFrost Posted December 5, 2005 Share Posted December 5, 2005 Hmm could you explain what this is doing please? =)thank you for your help I changed it, realized you only wanted to know 1st letter, it was going thru each letter. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 5, 2005 Moderators Share Posted December 5, 2005 Hey that's nice Gary!!... I did something like that once... but a bit drawn out 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...
sd333221 Posted December 5, 2005 Author Share Posted December 5, 2005 (edited) Func ChooseEncryption() $a_letter = StringMid(StringUpper($Username),1,1) Select Case $a_letters[$x] = 'A' Or $a_letters[$x] = 'B' Or $a_letters[$x] = 'C' Or $a_letters[$x] = 'D' MsgBox(0,"1st case",$a_letters[$x]) Case $a_letters[$x] = 'E' Or $a_letters[$x] = 'F' Or $a_letters[$x] = 'G' MsgBox(0,"2nd case",$a_letters[$x]) Case $a_letters[$x] = 'H' Or $a_letters[$x] = 'I' Or $a_letters[$x] = 'J' Or $a_letters[$x] = 'K' MsgBox(0,"3rd case",$a_letters[$x]) Case $a_letters[$x] = 'H' Or $a_letters[$x] = 'L' Or $a_letters[$x] = 'M' Or $a_letters[$x] = 'N' MsgBox(0,"4rd case",$a_letters[$x]) Case $a_letters[$x] = 'M' Or $a_letters[$x] = 'O' Or $a_letters[$x] = 'P' Or $a_letters[$x] = 'Q' MsgBox(0,"5rd case",$a_letters[$x]) Case $a_letters[$x] = 'R' Or $a_letters[$x] = 'S' Or $a_letters[$x] = 'T' Or $a_letters[$x] = 'U' MsgBox(0,"6rd case",$a_letters[$x]) Case $a_letters[$x] = 'V' Or $a_letters[$x] = 'W' Or $a_letters[$x] = 'X' Or $a_letters[$x] = 'Y' Or $a_letters[$x] = 'Z' MsgBox(0,"7rd case",$a_letters[$x]) Else Msgbox(0,"Error","Invalid Username!") EndSelect Endfunc Case $a_letters[$x] = 'A' Or $a_letters[$x] = 'B' Or $a_letters[$x] = 'C' Or $a_letters[$x] = 'D' Case ^Error Error: Variable used without being declared hmmm... I cant declare every Variable in my script.... This would be 30 more lines? Edited December 5, 2005 by sd333221 Link to comment Share on other sites More sharing options...
GaryFrost Posted December 5, 2005 Share Posted December 5, 2005 re-copy what i posted, made sure all syntax was correct SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
sd333221 Posted December 5, 2005 Author Share Posted December 5, 2005 re-copy what i posted, made sure all syntax was correctWow, it works!You are nice man Link to comment Share on other sites More sharing options...
Nuffilein805 Posted December 5, 2005 Share Posted December 5, 2005 Func ChooseEncryption() $a_letter = StringMid(StringUpper($Username),1,1) Select Case $a_letters[$x] = 'A' Or $a_letters[$x] = 'B' Or $a_letters[$x] = 'C' Or $a_letters[$x] = 'D' MsgBox(0,"1st case",$a_letters[$x]) Case $a_letters[$x] = 'E' Or $a_letters[$x] = 'F' Or $a_letters[$x] = 'G' MsgBox(0,"2nd case",$a_letters[$x]) Case $a_letters[$x] = 'H' Or $a_letters[$x] = 'I' Or $a_letters[$x] = 'J' Or $a_letters[$x] = 'K' MsgBox(0,"3rd case",$a_letters[$x]) Case $a_letters[$x] = 'H' Or $a_letters[$x] = 'L' Or $a_letters[$x] = 'M' Or $a_letters[$x] = 'N' MsgBox(0,"4rd case",$a_letters[$x]) Case $a_letters[$x] = 'M' Or $a_letters[$x] = 'O' Or $a_letters[$x] = 'P' Or $a_letters[$x] = 'Q' MsgBox(0,"5rd case",$a_letters[$x]) Case $a_letters[$x] = 'R' Or $a_letters[$x] = 'S' Or $a_letters[$x] = 'T' Or $a_letters[$x] = 'U' MsgBox(0,"6rd case",$a_letters[$x]) Case $a_letters[$x] = 'V' Or $a_letters[$x] = 'W' Or $a_letters[$x] = 'X' Or $a_letters[$x] = 'Y' Or $a_letters[$x] = 'Z' MsgBox(0,"7rd case",$a_letters[$x]) Else Msgbox(0,"Error","Invalid Username!") EndSelect Endfunc Case $a_letters[$x] = 'A' Or $a_letters[$x] = 'B' Or $a_letters[$x] = 'C' Or $a_letters[$x] = 'D' Case ^Error Error: Variable used without being declared hmmm... I cant declare every Variable in my script.... This would be 30 more lines? just to tell you why it hasn't worked: you declared "$a_letter" as your array, but you checked "$a_letters", this way it can't work my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Francis Lennert (France) Posted December 5, 2005 Share Posted December 5, 2005 Hello StringRegExp could be a good solution for this kind of test. $letter = "ah !!!!!!" $a_letter = FirstLetter( StringMid(StringUpper($letter),1,1) ) $letter = "Flunch !!!!!!" $a_letter = FirstLetter( StringMid(StringUpper($letter),1,1) ) $letter = "Hiiiii !!!!!!" $a_letter = FirstLetter( StringMid(StringUpper($letter),1,1) ) Func FirstLetter( $a_letter ) Select Case StringRegExp($a_letter,"^[ABCDE]",0) MsgBox(0,"1st case",$a_letter) Case StringRegExp($a_letter,"^[EFG]",0) MsgBox(0,"2nd case",$a_letter) Case StringRegExp($a_letter,"^[HIJK]",0) MsgBox(0,"3rd case",$a_letter) EndSelect endfunc HTH, Francis Link to comment Share on other sites More sharing options...
GaryFrost Posted December 5, 2005 Share Posted December 5, 2005 (edited) or if you have beta switch $letter = "gah" Switch StringMid(StringUpper($letter), 1, 1) Case 'A' To 'D' MsgBox(0, "1st case", $a_letter) Case 'E' To 'G' MsgBox(0, "2nd case", $a_letter) Case 'H' To 'K' MsgBox(0, "3rd case", $a_letter) EndSwitch Edited December 5, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Greenseed Posted December 5, 2005 Share Posted December 5, 2005 (edited) $firstletter = Asc(StringLeft($username,1)) it will return the ASCII code for the caractere after you do case like other post case $firstletter > 64 and $firstletter < 69 or $firstletter > 96 and $firstletter < 101 blabla 65 to 68 = A,B,C,D 97 to 100 = a,b,c,d is another way to do it! with less coding if username is not case sentive you can format $username to get the proper case and analyse it after! it will be a little faster! and many thx for the Switch function gafrost! it pretty kewl! Edited December 5, 2005 by Greenseed GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You. 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