m1975michael Posted August 23, 2014 Share Posted August 23, 2014 (edited) How can I get $iIPO2 and $iIPO3 values from the GetPCNumber function into the PingPCGateway function? PingPCGateway() ;Ping PC Gateway Func PingPCGateway() GetPCNumber() MsgBox(0, "", $iIPO2 & " " & $iIPO3) Local $iIPO1 = 10 Local $iIPO4 = 1 Local $iIPAddress = ($iIPO1 & "." & $iIPO2 & "." & $iIPO3 & "." & $iIPO4) Run(@ComSpec & " /k" & "ping.exe -t " & $iIPAddress) EndFunc ;==>PingPCGateway ;Extrapolate Second and Third Octet From PC Number Func GetPCNumber() Local $iPCNumber = InputBox("Enter PC Number", "Enter a 4 digit PC Number") If $iPCNumber > "" Then Local $iIPO2 = StringRegExpReplace($iPCNumber, "\d{2}$", "") Local $iIPO3 = StringRegExpReplace($iPCNumber, "^\d{2}", "") If StringTrimRight($iIPO2, 1) = 0 Then $iIPO2 = StringTrimLeft($iIPO2, 1) EndIf If StringTrimRight($iIPO3, 1) = 0 Then $iIPO3 = StringTrimLeft($iIPO3, 1) EndIf If $iIPO3 = 0 Then $iIPO3 = 100 EndIf ElseIf $iPCNumber = "" Then MsgBox(262160, "Invalid Entry", "Please Enter a Valid Four Digit PC Number") EndIf ;MsgBox(0, "", $iIPO2) ;MsgBox(0, "", $iIPO3) EndFunc ;==>GetPCNumber Edited August 23, 2014 by m1975michael Link to comment Share on other sites More sharing options...
Developers Jos Posted August 23, 2014 Developers Share Posted August 23, 2014 Using parameters with ByRef in your Func? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
m1975michael Posted August 23, 2014 Author Share Posted August 23, 2014 Using parameters with ByRef in your Func? Jos I am not sure how to do that can you please show me. Link to comment Share on other sites More sharing options...
Developers Jos Posted August 23, 2014 Developers Share Posted August 23, 2014 Open the Helpfile on Func where this is nicely explained. Give it a tried and comeback with some code in case you have issues. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
m1975michael Posted August 24, 2014 Author Share Posted August 24, 2014 Please review my code and see if there are any changes you suggest. Is there a good way to get the script to work with out defining the local variables in the while loop. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=CEDUtilv3.2Personal.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_Res_Fileversion=3.2 #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_AU3Check_Stop_OnWarning=y #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WinAPI.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiIPAddress.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Global $hCEDForm = GUICreate("CED Help Desk Utility", 443, 274, 242, 160) GUISetBkColor(0xA6CAF0) Global $hPCTools = GUICtrlCreateGroup("Profit Center Tools", 24, 16, 185, 241) Global $hLabelPCNum = GUICtrlCreateLabel("PC Number", 40, 40, 58, 17) Global $hPCNumInput = GUICtrlCreateInput("", 40, 59, 31, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) GUICtrlSetLimit(-1, 4) Global $hButtonCheckBoxStatus = GUICtrlCreateButton("Execute Checked Items", 40, 212, 125, 25) Global $hCheckboxPingPC = GUICtrlCreateCheckbox("Ping PC Gateway", 40, 92, 115, 25) Global $hCheckboxFortiWiFiWeb = GUICtrlCreateCheckbox("Forti WiFi Web Login", 40, 122, 115, 25) Global $hCheckboxFortiWiFiPutty = GUICtrlCreateCheckbox("Forti WiFi Putty Login", 40, 152, 115, 25) Global $hCheckboxRDCEDSvr = GUICtrlCreateCheckbox("Remote Desktop CED Server", 40, 182, 155, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) Global $hLableNetworkTools = GUICtrlCreateGroup("Network Tools", 232, 16, 185, 241) Global $hButtonPingIPInput = GUICtrlCreateButton("Ping IP Address", 248, 122, 125, 25) Global $hCheckboxClearIP = GUICtrlCreateCheckbox("Clear IP After Execution", 248, 92, 127, 25) Global $hLabelIPAddress = GUICtrlCreateLabel("IP Address", 248, 40, 58, 17) Global $hIPAddressInput = GUICtrlCreateInput("", 248, 59, 105, 21) GUICtrlSetLimit(-1, 15) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hButtonPingIPInput ;PingIPInput() Case $hButtonCheckBoxStatus Local $iIPO2 Local $iIPO3 Local $iIPAddress GetPCNumber($iIPO2, $iIPO3) CheckBoxStatus() EndSwitch Local $aCursorInfo = GUIGetCursorInfo($hCEDForm) If $aCursorInfo[2] Then If $aCursorInfo[4] = $hPCNumInput Then GUICtrlSetData($hPCNumInput, "") EndIf WEnd _WinAPI_SetFocus(ControlGetHandle("CED Help Desk Utility", "", $hPCNumInput)) ;Profit Center Tools ---------- ;Ping PC Gateway Func PingPCGateway() Local $iIPO1 = 10 Local $iIPO4 = 1 IPAddress($iIPO1, $iIPO4, $iIPAddress) If $iIPO2 = 0 Then Return EndIf PingCmd($iIPO1, $iIPO4) EndFunc ;==>PingPCGateway ;Combine IP Address Octets Func IPAddress($iIPO1, $iIPO4, ByRef $iIPAddress) $iIPAddress = ($iIPO1 & "." & $iIPO2 & "." & $iIPO3 & "." & $iIPO4) EndFunc ;==>IPAddress ;Ping Command Func PingCmd($iIPO1, $iIPO4) Run(@ComSpec & " /k" & "ping.exe -t " & $iIPAddress) EndFunc ;==>PingCmd ;Extrapolate Second and Third Octet From PC Number Func GetPCNumber(ByRef $iIPO2, ByRef $iIPO3) Local $iPCNumber = GUICtrlRead($hPCNumInput) If $iPCNumber > "" Then $iIPO2 = StringRegExpReplace($iPCNumber, "\d{2}$", "") If $iIPO2 = 0 Then MsgBox(262160, "Invalid Entry", "Please Enter a Valid Four Digit PC Number") _WinAPI_SetFocus(ControlGetHandle("CED Help Desk Utility", "", $hPCNumInput)) GUICtrlSetData($hPCNumInput, "") EndIf $iIPO3 = StringRegExpReplace($iPCNumber, "^\d{2}", "") If StringTrimRight($iIPO2, 1) = 0 Then $iIPO2 = StringTrimLeft($iIPO2, 1) EndIf If StringTrimRight($iIPO3, 1) = 0 Then $iIPO3 = StringTrimLeft($iIPO3, 1) EndIf If $iIPO3 = 0 Then $iIPO3 = 100 EndIf ;MsgBox(0, "", $iIPO2) ;MsgBox(0, "", $iIPO3) ElseIf $iPCNumber = "" Then MsgBox(262160, "Invalid Entry", "Please Enter a Valid Four Digit PC Number") _WinAPI_SetFocus(ControlGetHandle("CED Help Desk Utility", "", $hPCNumInput)) EndIf EndFunc ;==>GetPCNumber ;Check Check Box Status For PC Tools Func CheckBoxStatus() Local $iPCNumber = GUICtrlRead($hPCNumInput) If $iPCNumber = "" Then Return Else Local $CheckboxPingPCStatus = ControlCommand($hCEDForm, "", $hCheckboxPingPC, "IsChecked") Local $CheckboxFortiWiFiWebStatus = ControlCommand($hCEDForm, "", $hCheckboxFortiWiFiWeb, "IsChecked") Local $CheckboxFortiWiFiPuttyStatus = ControlCommand($hCEDForm, "", $hCheckboxFortiWiFiPutty, "IsChecked") Local $hCheckboxRDCEDSvrStatus = ControlCommand($hCEDForm, "", $hCheckboxRDCEDSvr, "IsChecked") If $CheckboxPingPCStatus = 1 Then PingPCGateway() EndIf If $CheckboxFortiWiFiWebStatus = 1 Then ;FortiWiFiWebLogin() EndIf If $CheckboxFortiWiFiPuttyStatus = 1 Then ;FortiWiFiPuttyLogin() EndIf If $hCheckboxRDCEDSvrStatus = 1 Then ;RDCEDSvr() EndIf EndIf EndFunc ;==>CheckBoxStatus Link to comment Share on other sites More sharing options...
jguinch Posted August 24, 2014 Share Posted August 24, 2014 Are you sure about this : If $iPCNumber > "" Then ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
m1975michael Posted August 24, 2014 Author Share Posted August 24, 2014 (edited) Are you sure about this : If $iPCNumber > "" Then ? I want to process the following as long as the box is not empty. I really want to only accept 4 digit number. Edited August 24, 2014 by m1975michael Link to comment Share on other sites More sharing options...
guinness Posted August 24, 2014 Share Posted August 24, 2014 You want <> or Not ($var = '') 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...
kylomas Posted August 24, 2014 Share Posted August 24, 2014 Is there a good way to get the script to work with out defining the local variables in the while loop. If you are asking about vars $iIPO2, $iIPO3 and $iIPAddress then yes, define them at the top of the script. These vars are in GLOBAL scope because of where they are defined (outside of any function). Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
m1975michael Posted August 27, 2014 Author Share Posted August 27, 2014 If you are asking about vars $iIPO2, $iIPO3 and $iIPAddress then yes, define them at the top of the script. These vars are in GLOBAL scope because of where they are defined (outside of any function). Is there a better way to write the script with out making those variables global? i have tried but failed. 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