FinalVersion Posted February 12, 2010 Posted February 12, 2010 (edited) First of, I assume StringIsAlpha means any letter and StringIsDigit means any number. If I'm wrong correct met. Anyway, I want them to ignore ".", on first glance there isn't any additional parameters, but I'm certain there is away. Real Quick Exmaple: If StringIsAlpha($Host) Then $HostType = "Address" ; www.google.com.au ElseIf StringIsDigit($Host) Then $HostType = "IP" ; 127.0.0.1 Else $HostType = "Invalid" EndIf At the moment they don't ignore the ".". Edited February 12, 2010 by FinalVersion [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
t0ddie Posted February 12, 2010 Posted February 12, 2010 (edited) $result = StringInStr($Host, ".") check to see if its true and then if it is, you can ignore it. EDIT: you can also stringtrim if you still need the other data in the string. Edited February 12, 2010 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.
FinalVersion Posted February 12, 2010 Author Posted February 12, 2010 Forgive me if I'm wrong, but all that tells me is if it contains a ".". And honestly I don't see how that helps, correct me though, it's really late [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
t0ddie Posted February 12, 2010 Posted February 12, 2010 (edited) Forgive me if I'm wrong, but all that tells me is if it contains a ".". And honestly I don't see how that helps, correct me though, it's really late i don't understand what you mean by wanting to "ignore" it. $result = StringInStr($Host, ".") if $result = 1 then ;ignore or do nothing else If StringIsAlpha($Host) Then $HostType = "Address" ; www.google.com.au ElseIf StringIsDigit($Host) Then $HostType = "IP" ; 127.0.0.1 Else $HostType = "Invalid" EndIf endif i nested the if statement here just to show you an example quickly but there are better ways to code this. EDIT: are you trying to simply remove the "." from the strings? Edited February 12, 2010 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.
Moderators Melba23 Posted February 12, 2010 Moderators Posted February 12, 2010 FinalVersion,Just remove any "." characters from the test string with StringReplace before you test with StringIsAlpha/Digit. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Â
FinalVersion Posted February 12, 2010 Author Posted February 12, 2010 (edited) It's a GUI with an input box (My fault for not mentioning that), that would be to confusing. Also I'm not trying to remove them, basically I want to ignore if there is a "." in the string, StringIsAlpha would still be true and the same for StringIsDigit. Edited February 12, 2010 by FinalVersion [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
t0ddie Posted February 12, 2010 Posted February 12, 2010 you could save a new variable where you remove the "." then check the other parameters of that new variable against your alpha and digit that way the old variable can still be used and you did not remove anything. Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.
FinalVersion Posted February 12, 2010 Author Posted February 12, 2010 So your saying... 1. Make the string without the "." in a new variable. 2. Check if it's Alpha or Digit 3. Continue on with $Host Why didn't I think of that? Maybe the fact it's 2:00AM? [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
Moderators Melba23 Posted February 12, 2010 Moderators Posted February 12, 2010 (edited) Finalversion, t0ddie understood perfectly - just create a new variable for testing purposes and leave the original alone. Go and get some sleep - it sounds like you need it! M23 Edit: I see the penny dropped! Sleep well! Edited February 12, 2010 by Melba23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Â
FinalVersion Posted February 12, 2010 Author Posted February 12, 2010 Not yet Must finish this, I'm determ.... zzzz Anyway after that powernap. $String = "www.google.com.au" $Result = StringReplace($String, "", ".") MsgBox(0, "Hey", $Result) I have no idea what to put for "searchstring/start" (2nd parameter). "The substring to search for or the character position to start the replacement." Make no sense at the moment to me. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
t0ddie Posted February 12, 2010 Posted February 12, 2010 $String = "www.google.com.au" $Result = StringReplace($String, ".", "") MsgBox(0, "Hey", $Result) ;lol? Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.
FinalVersion Posted February 12, 2010 Author Posted February 12, 2010 Ah so the first one is what you want to find, and second what to replace with. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
t0ddie Posted February 12, 2010 Posted February 12, 2010 yes and glad i could help i usually ask questions on here but hey why not answer some too right? i have been here long enough. even though you are falling asleep it still counts as me helping hahaha Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.
FinalVersion Posted February 12, 2010 Author Posted February 12, 2010 Indeed, last problem I swear. Let's say they don't enter a "." (they just enter gibberish), what can I do about that? ; Declare some variables Local $HostType Local $ReplaceResult = StringReplace($Host, ".", "") ; Check If Required Fields Are Filled Out Etc If StringIsAlpha($ReplaceResult) Then $HostType = "Address" ElseIf StringIsDigit($ReplaceResult) Then $HostType = "IP" Else $HostType = "Invalid" EndIf MsgBox(0, "", $HostType) [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
t0ddie Posted February 12, 2010 Posted February 12, 2010 well you can only make code to a certain extent to be user friendly or "idiot proof" you can make a custom error message so when the data that they try to use does not work i.e. the host does not load... you can tell them to check what they entered and re-enter it. other than that you are going to have to do a series of things. check to make sure the length is correct so that anything over or under a certain number is rejected. check if there are symbols in it obviously with alpha and digit. as for a typo in the numbers or digits there is nothing you can do about that. but you can certainly detect this dslkj or this 1234.5432.1234.5432 or this 123.54.6*.234 Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.
FinalVersion Posted February 12, 2010 Author Posted February 12, 2010 (edited) but you can certainly detect thisdslkjor this 1234.5432.1234.5432or this 123.54.6*.234How?As for the typo, lets say they missed typed google.com, after the program tries to connect, and fails. I'll throw something at them(a dictionary). Edited February 12, 2010 by FinalVersion [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
t0ddie Posted February 12, 2010 Posted February 12, 2010 How?As for the typo, lets say they missed typed google.com, after the program tries to connect, and fails. I'll throw something at them(a dictionary).first two are improper length.check to see what length the smallest and biggest valid strings areany string over or under that you can throw an error.third one is a symbol was entered.you can check to see if its neither alpha or digit then you know there is a symbol or space in it.first eliminate the spaces just like you eliminated the "."then you can use a loop to check the length of the string, save it into a new variable, trim the new variable one character at a time and keep checking it until you find the culprit. then display it and say HEY! you see this? you cant do that! or something. Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.
FinalVersion Posted February 12, 2010 Author Posted February 12, 2010 Ok, I'm going to sleep. But if you want to be nice, maybe you could whip that up [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
t0ddie Posted February 12, 2010 Posted February 12, 2010 (edited) ok fine i will be nice ip only is easy but a website can be any length first you remove the "." AND the " " from the $Host variable. also to avoid problems with the :// symbols you want to remove http:// then check if its a number or letters seperately and then check its length. the length should be 9 for this and that should be your minimum for numbers the length of a minimum website like www.a.com is 7 and you can set max at whatever you want. expandcollapse popup$Host = "ertuh4r432#5340958734587" $ReplaceResult = StringReplace($Host, ".", "") $ReplaceResult = StringReplace($ReplaceResult, " ", "") $ReplaceResult = StringReplace($ReplaceResult, "http://", "") $len = stringlen($ReplaceResult) If StringIsDigit($ReplaceResult) Then if $len < 9 then msgbox(0,"test","error... too short") exit endif if $len > 9 then msgbox(0,"test","error... too long") exit else $HostType = "IP" endif endif If StringIsAlpha($ReplaceResult) Then if $len < 7 then msgbox(0,"test","error... too short") exit endif if $len > 100 then msgbox(0,"test","error... too long") exit else $HostType = "Address" endif endif Do $ReplaceResult2 = stringtrimleft($ReplaceResult,$len - 1) if not StringIsAlNum($ReplaceResult2) Then msgbox(0,"test",$ReplaceResult2 & " Is not allowed") exit endif $ReplaceResult = stringtrimright($ReplaceResult,1) $len = $len - 1 until $len = 0 I think it should work for the most part the coding may be slightly sloppy haha Edited February 12, 2010 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.
FinalVersion Posted February 13, 2010 Author Posted February 13, 2010 Yeah thanks. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
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