Robonglious Posted June 1, 2012 Share Posted June 1, 2012 Hello, I'm very new to this but I love it so far. I've written a couple of really basic programs but I need to do a more complex one and I'm having some trouble with how it will work. What I'd like to do is have the program look up the local IP Address and add that number with the last octet changed to 55 and save that to a variable. Is this possible or does anyone have any directions I can look in? Thanks in advance, this stuff is rad. Link to comment Share on other sites More sharing options...
UEZ Posted June 1, 2012 Share Posted June 1, 2012 Can you give an example what you mean? Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Robonglious Posted June 1, 2012 Author Share Posted June 1, 2012 Yes, What I want to do is have the program look up the IP address of the machine and save to a var. So lets say the IP of the machine is 10.XXX.XXX.XXX, the next step is to have the program change the last number of this series to 55 so it would read 10.XXX.XXX.55. Does that make sense? Link to comment Share on other sites More sharing options...
armoros Posted June 1, 2012 Share Posted June 1, 2012 Sorry to ask but why to do that ? [font="verdana, geneva, sans-serif"] [/font] Link to comment Share on other sites More sharing options...
UEZ Posted June 1, 2012 Share Posted June 1, 2012 Something like that? $ip = @IPAddress1 $new = StringRegExpReplace($ip, "(d{1,3}.d{1,3}.d{1,3}.)d{1,3}", "${1}55") MsgBox(0, "Test", "New IP: "& $new) Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Robonglious Posted June 1, 2012 Author Share Posted June 1, 2012 Hmmm, I'll need to look into that StringRegExpReplace. This will be used to add network printers at different locations. Thanks for your help UEZ, I'm pretty psyched about using this. Link to comment Share on other sites More sharing options...
UEZ Posted June 1, 2012 Share Posted June 1, 2012 Here another way: $ip = @IPAddress1 $new = StringLeft($ip, StringInStr($ip, ".", 0, -1)) & "55" MsgBox(0, "Test", "New IP: "& $new) Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Robonglious Posted June 1, 2012 Author Share Posted June 1, 2012 Your addition is working perfectly but DOS is telling me "INVALID PARAMETER", I'll keep plugging away. How did you find these things you are showing me? Link to comment Share on other sites More sharing options...
UEZ Posted June 1, 2012 Share Posted June 1, 2012 Your addition is working perfectly but DOS is telling me "INVALID PARAMETER", I'll keep plugging away.How did you find these things you are showing me?Practical knowledge. Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Robonglious Posted June 1, 2012 Author Share Posted June 1, 2012 So the MVP title is well earned. Hopefully I can get up to speed to be able to make these types of things. Thanks again for your help Link to comment Share on other sites More sharing options...
guinness Posted June 1, 2012 Share Posted June 1, 2012 (edited) I know UEZ has answered your question, but here's another SRE. Local $sIPAddress = @IPAddress1 Local $sReturn = StringRegExpReplace($sIPAddress, '((d{1,3}.){3})d{1,3}', '${1}55') MsgBox(4096, '', $sReturn & @CRLF) Edit: Also just to show that there are more ways to achieve the same goal here is using the native AutoIt functions (though UEZ's is way more efficient! Hint: he doesn't use StringLen, therefore one less function call.) Local $sIPAddress = @IPAddress1 Local $sReturn = StringTrimRight($sIPAddress, StringLen($sIPAddress) - StringInStr($sIPAddress, ".", 0, -1)) & "55" MsgBox(4096, '', $sReturn & @CRLF) Edited June 1, 2012 by guinness Robonglious 1 UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Robonglious Posted June 4, 2012 Author Share Posted June 4, 2012 I don't fully understand how StringInStr is working. It doesn't make sense how it takes off the last octet. I see that the string is declared and the substring is "." but it seems like this would subtract 3 each time which is incorrect. I'm sure I just don't understand how this is working. Thanks for your help Link to comment Share on other sites More sharing options...
JohnOne Posted June 4, 2012 Share Posted June 4, 2012 StringLen() is telling the length of the whole string StringInStr() is telling the position of the last "." So StringLen() - StringInStr() gives the number of chars to trim from the right. Then concat 55 Robonglious 1 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...
Robonglious Posted June 4, 2012 Author Share Posted June 4, 2012 Great solutions, thanks everyone! Link to comment Share on other sites More sharing options...
Robonglious Posted June 4, 2012 Author Share Posted June 4, 2012 aha!: Link to comment Share on other sites More sharing options...
guinness Posted June 4, 2012 Share Posted June 4, 2012 (edited) Thanks JohnOne. I should've explained it in my post really, but wasn't think at the time. Edited June 4, 2012 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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