autosc Posted February 7, 2007 Share Posted February 7, 2007 I am trying to not allow the charters \ and ? from the input box - Works for ? not for \ why ? CODE#include <String.au3> #include <array.au3> $checkks = InputBox("DONT ALLOW \ ?", "ELIMINATE \ ?", "", "", _ -1, -1, 0, 0) $REPL = StringRegExpReplace($checkks, '[\?]', '@') $result = StringInStr($REPL, "@") If $result > 0 Then MsgBox(0,"bad ", $result) Else MsgBox(0,"good ", $result) endif Link to comment Share on other sites More sharing options...
nobbe Posted February 7, 2007 Share Posted February 7, 2007 hi have you tried \\ yet? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 7, 2007 Moderators Share Posted February 7, 2007 Your If/Then statement for what it looks like you are trying to do is wrong... Do you want to replace all \ and ??$checkks = InputBox("DONT ALLOW \ ?", "ELIMINATE \ ?", "", "", _ -1, -1, 0, 0) $REPL = StringRegExpReplace($checkks, '\\|\?', '@') MsgBox(0, '', $REPL) 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...
autosc Posted February 7, 2007 Author Share Posted February 7, 2007 hihave you tried \\ yet?The user may enter just ones the charter \if the user repeats ..works ...But if it works for other charters why not for " \ " Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 7, 2007 Moderators Share Posted February 7, 2007 The user may enter just ones the charter \if the user repeats ..works ...But if it works for other charters why not for " \ "Turtles... 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...
autosc Posted February 7, 2007 Author Share Posted February 7, 2007 Turtles...what is that ? a function in autoit ? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 7, 2007 Moderators Share Posted February 7, 2007 what is that ? a function in autoit ?A way of confusing you, as you've chosen to confuse us. Try to be a bit more literate when asking for help on what exactly you want help with. I hate trying to decipher request more than I do deciphering code itself. 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...
nobbe Posted February 7, 2007 Share Posted February 7, 2007 The user may enter just ones the charter \if the user repeats ..works ...But if it works for other charters why not for " \ "hi , ehm you best use SmOke_Ns codea little explanation : the "\" is often called the "Escape " character - to display or search for special character like "? * \" - so if you search for "\" you need to escape it like "\\" in your search statement ..nobbe Link to comment Share on other sites More sharing options...
autosc Posted February 7, 2007 Author Share Posted February 7, 2007 hi , ehm you best use SmOke_Ns codea little explanation : the "\" is often called the "Escape " character - to display or search for special character like "? * \" - so if you search for "\" you need to escape it like "\\" in your search statement ..nobbeSmoke >I will try to be literate in autoit . The reason why i want resolve this problem is as you stated in your post yesterday which is Good ! my question may sound easy .... but i faced with a problem how to avoid "autoit error messages " . and this was a way to my particular situation :The user may enter just ones "\" in my input box .the solution might be to evaluate this charter separately , but i was evaluating with other charters . an the evalution for this charter failed .How feasible would it be to have the option? Personally, I'd like to see it like COM error handling, where you can trap the error, determine it's relevance, and choose to Prompt with exit / Prompt and continue / Suppress and exit / Suppress and continue.Speaking with a respected forum member tonight, they made the comment, even the best of us screw something up every now and again. Just sucks to know that someone is able to sometimes peak at your code, even when you don't want them too, or finding out this way that it's an AutoIt executable, and get funny ideas (I'll leave this to the imagination)./ErrorStdOut, in many of my own cases isn't a good solution. The perfect solution, obviously, is to never make a mistake, but realistically speaking, that's not always going to happen.and learning to make a mistake . Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 7, 2007 Moderators Share Posted February 7, 2007 (edited) 1 slash and how many question marks are they allowed?Edit:Even better, show us an example of an improper string and show us how you would like to correct it (A before and after).Edit2:Without an example of a Bad string / Good string... I'm left to assume this is what you are trying to do:$checkks = InputBox("DONT ALLOW \ ?", "ELIMINATE \ ?", "", "", -1, -1, 0, 0) If @error = 1 Then Exit $REPL = StringRegExpReplace($checkks, '\\{2,}', '\1\\') $REPL = StringRegExpReplace($REPL, '\?', '\1@') MsgBox(0, '', $REPL) Edited February 7, 2007 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...
autosc Posted February 7, 2007 Author Share Posted February 7, 2007 1 slash and how many question marks are they allowed? here is your code modified from last post with all evaluated charters : the variable $REPL returns @ to all charters except \ which returns itself why \ not returning @ ? CODE$checkks = InputBox("DONT ALLOW \ ?", "ELIMINATE \ ?", "", "", _ -1, -1, 0, 0) $REPL = StringRegExpReplace($checkks, '[><|"?*+\/]', '@') MsgBox(0, '', $REPL) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 7, 2007 Moderators Share Posted February 7, 2007 here is your code modified from last post with all evaluated charters : the variable $REPL returns @ to all charters except \ which returns itself why \ not returning @ ? CODE$checkks = InputBox("DONT ALLOW \ ?", "ELIMINATE \ ?", "", "", _ -1, -1, 0, 0) $REPL = StringRegExpReplace($checkks, '[><|"?*+\/]', '@') MsgBox(0, '', $REPL)I think I answered this already kind of: [><|"?*+\/\\]is probably what you want. 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...
nobbe Posted February 7, 2007 Share Posted February 7, 2007 hi i know im repeating myself when i answer "\\" ?? CODE$checkks = "test\test?test*test&test|test/" $REPL = StringRegExpReplace($checkks, '[><|"?&*+\/]', '@') MsgBox(0, '', $REPL) $checkks = "test\test?test*test&test|test/" $REPL = StringRegExpReplace($checkks, '[><|"?&*+\\/]', '@') MsgBox(0, '', $REPL) Link to comment Share on other sites More sharing options...
autosc Posted February 7, 2007 Author Share Posted February 7, 2007 hi i know im repeating myself when i answer "\\" ?? CODE$checkks = "test\test?test*test&test|test/" $REPL = StringRegExpReplace($checkks, '[><|"?&*+\/]', '@') MsgBox(0, '', $REPL) $checkks = "test\test?test*test&test|test/" $REPL = StringRegExpReplace($checkks, '[><|"?&*+\\/]', '@') MsgBox(0, '', $REPL) Thank you ! Problem solved .for my particular case. If the user write his name in the input box properly , no problem . But if some body gives your application a hard strike , " The autoit eroor message comes , together with all your codes ". I have even tested some applications in this forum with users input . and the autoit error message appears with a collection of codes . if you try with all your charters . I dont know why autoit is so sensitive ? i tried all methods like "ErrorHandlerRegister " not worked . to surpress errors and go back to the scrren (GUICtrlSetState(-1,$GUI_SHOW) or close the application. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 7, 2007 Moderators Share Posted February 7, 2007 I dont know why autoit is so sensitive ?Seeing as we still have no real code to look at and decipher, we don't know why it's sensitive either . 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...
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