PDowning Posted April 26, 2013 Share Posted April 26, 2013 I have made a script that pulls the PC IP address, compare the 2nd octect number and open a website based on that comparison. The problem is that it has to be compared to nealy 90 sites and it makes for one large If .. .EndIf. Here is a snippet of the code: If Number ($Octet[2]) = 118 Then run ("c:\Program Files\Internet Explorer\IEXPLORE.EXE http://website/common/welcome.jsp?site=101") ElseIf Number ($Octet [2]) = 123 Then run ("c:\Program Files\Internet Explorer\IEXPLORE.EXE http://website/common/welcome.jsp?site=102") ElseIf Number ($Octet [2]) = 195 Then run ("c:\Program Files\Internet Explorer\IEXPLORE.EXE http://website/common/welcome.jsp?site=105") this continues till the final ElseIF comparison. How can this be more efficient? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 26, 2013 Moderators Share Posted April 26, 2013 PDowning,Look at Switch in the Help file. 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 Link to comment Share on other sites More sharing options...
JohnOne Posted April 26, 2013 Share Posted April 26, 2013 Also, arrays and For..To..Next Loop AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
PDowning Posted April 26, 2013 Author Share Posted April 26, 2013 (edited) According to my puny brain power here, I can't see how those help due to the IP's NOT being in a straight order(ex. 101,102,103,104). They, thanks to the brilliant engineering brain power around here, are all over the place. Also the number at the end of the IExplorer line are also not in order. Guess I'm just not wrapping a head around this yet. Edited: Not knocking your suggestions, thank you very much for them. I just can't wrap my head around how it helps. Edited April 26, 2013 by PDowning Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 26, 2013 Moderators Share Posted April 26, 2013 PDowning, JohnOne's idea is better than mine - and here is how you might implement something like it: #include <Array.au3> ; Creat an array to link the octet with the site ID Global $aListing[3][2] = [[118, 101], [123, 102], [195, 105]] ; Simulate the octet Global $Octet[3] $Octet[2] = 118 ; Look for the octet $iIndex = _ArraySearch($aListing, Number($Octet[2])) If $iIndex <> -1 Then ; Use the related site ID ConsoleWrite("c:\Program Files\Internet Explorer\IEXPLORE.EXE http://website/common/welcome.jsp?site=" & $aListing[$iIndex][1] & @CRLF) ;Run("c:\Program Files\Internet Explorer\IEXPLORE.EXE http://website/common/welcome.jsp?site=" & $aListing[$iIndex][1]) EndIf All clear? 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 Link to comment Share on other sites More sharing options...
PDowning Posted April 26, 2013 Author Share Posted April 26, 2013 Gotcha .... that makes sense now. I had thought of something similar when I was sitting to write the script, but couldn't visualize how to put it on paper, so to speak. thanks much 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