Rildoy Posted March 16, 2017 Share Posted March 16, 2017 I made two code sequences separately and then put them together, but I get a variable declaration error, please support it with my project. "D:\Techint\Programacion\Final_1303.au3" (137) : ==> Variable used without being declared.: For $i = 0 To UBound($aPCAlias) - 1 For $i = 0 To UBound(^ ERROR I made two code sequences separately and then put them together, but I get a variable declaration error, please support it with my project. I send my code Link to comment Share on other sites More sharing options...
Rildoy Posted March 16, 2017 Author Share Posted March 16, 2017 Just now, Rildoy said: I made two code sequences separately and then put them together, but I get a variable declaration error, please support it with my project. "D:\Techint\Programacion\Final_1303.au3" (137) : ==> Variable used without being declared.: For $i = 0 To UBound($aPCAlias) - 1 For $i = 0 To UBound(^ ERROR I made two code sequences separately and then put them together, but I get a variable declaration error, please support it with my project. I send my code #include <file.au3> #include <array.au3> #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <ListviewConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("Datos de Equipos", 279, 261, -1, -1) $Button1 = GUICtrlCreateButton("Obtener Datos Locales", 16, 16, 249, 49) $Admin = GUICtrlCreateInput(".\TEIAdmin", 18, 96, 249, 21) $Label1 = GUICtrlCreateLabel("Ingresar datos de equipo Remoto", 24, 72, 192, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetCursor (-1, 2) $Password = GUICtrlCreateInput("Password", 18, 128, 249, 21) $Button2 = GUICtrlCreateButton("Obtener datos de Equipo Remioto", 16, 192, 249, 49) $Host = GUICtrlCreateInput("Ingresar Host", 18, 160, 249, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button2 _WritePCInfo() EndSwitch WEnd #Region Datos Local $fp_PCInfo = @ScriptDir & "\PCInfo.txt" Local $strPCInfoFormat = "csv" If FileExists($fp_PCInfo) Then FileDelete($fp_PCInfo) EndIf Local $strNicConfig = "wmic /Node:$Host /User:$Admin /Password:$Password nicconfig list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo Local $strOS = "wmic /Node:$Host /User:$Admin /Password:$Password OS list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo Local $strBOIS = "wmic /Node:$Host /User:$Admin /Password:$Password bios list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo Local $strMemorychip = "wmic /Node:$Host /User:$Admin /Password:$Password memorychip get manufacturer, PartNumber,SerialNumber,Capacity,DeviceLocator,MemoryType,Name,TotalWidth /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo Local $strCPU = "wmic /Node:$Host /User:$Admin /Password:$Password CPU list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo Local $strDiskdrive = "wmic /Node:$Host /User:$Admin /Password:$Password diskdrive list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo Local $strSoundDev = "wmic /Node:$Host /User:$Admin /Password:$Password SoundDev list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo Local $strBaseboard = "wmic /Node:$Host /User:$Admin /Password:$Password baseboard list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo Local $aPCAlias[8][2] $aPCAlias[0][0] = "OS" $aPCAlias[0][1] = $strOS $aPCAlias[1][0] = "BIOS" $aPCAlias[1][1] = $strBOIS $aPCAlias[2][0] = "Baseboard" $aPCAlias[2][1] = $strBaseboard $aPCAlias[3][0] = "CPU" $aPCAlias[3][1] = $strCPU $aPCAlias[4][0] = "Memory" $aPCAlias[4][1] = $strMemorychip $aPCAlias[5][0] = "Diskdrive" $aPCAlias[5][1] = $strDiskdrive $aPCAlias[6][0] = "Sound" $aPCAlias[6][1] = $strSoundDev $aPCAlias[7][0] = "Net" $aPCAlias[7][1] = $strNicConfig _WritePCInfo() Local $aArray = FileReadToArray($fp_PCInfo) Local $iRowIndex = 1 If UBound($aArray) <= 8 Then MsgBox(0, "", "Can not collect PC information.") Exit EndIf #Region ### START Koda GUI section ### Form= $formPC = GUICreate("Información de Equipo", 1000, 437, 192, 124) $tabType = GUICtrlCreateTab(10, 10, 982, 420) GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) Local $lvHandle[UBound($aPCAlias)] Local $strCurrentString, $aTemp For $i = 0 To UBound($aPCAlias) - 1 GUICtrlCreateTabItem($aPCAlias[$i][0]) $strCurrentString = $aArray[$iRowIndex] $lvHandle[$i] = GUICtrlCreateListView(StringReplace($strCurrentString, ",", "|"), 16, 35, 970, 390, bitor($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) GUISetBkColor(0x00E0FFFF) $iRowIndex += 1 While $aArray[$iRowIndex] <> "" $strCurrentString = $aArray[$iRowIndex] If $aPCAlias[$i][0] == "Memory" Then $aTemp = StringSplit($strCurrentString, ",", 2) $aTemp[1] = _SwitchToMb($aTemp[1]) $strCurrentString = _ArrayToString($aTemp, ",") EndIf If $aPCAlias[$i][0] == "Diskdrive" Then $aTemp = StringSplit($strCurrentString, ",", 2) $aTemp[5] = _SwitchToMb($aTemp[5]) $strCurrentString = _ArrayToString($aTemp, ",") EndIf GUICtrlCreateListViewItem(StringReplace($strCurrentString, ",", "|"), $lvHandle[$i]) $iRowIndex += 1 If $iRowIndex = UBound($aArray) Then ExitLoop WEnd $iRowIndex += 1 ;jump the empty row Next GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _SwitchToMb($strNumber) Return String(int(Number($strNumber) / (1024 * 1024))) & " Mb" EndFunc Func _WritePCInfo() For $i = 0 To UBound($aPCAlias) - 1 ;ConsoleWrite($aPCAlias[$i][1] & @CRLF) RunWait(@ComSpec & " /c " & $aPCAlias[$i][1], @ScriptDir, @SW_HIDE) _AppendLineToFile($fp_PCInfo, @CRLF) Next EndFunc Func _AppendLineToFile($strFilepath, $strContent) Local $hFileOpen = FileOpen($strFilepath, $FO_APPEND) If $hFileOpen = -1 Then MsgBox(0, "", "An error occurred when reading the file.") Return False EndIf ; Write data to the file using the handle returned by FileOpen. FileWriteLine($hFileOpen, $strContent) ; Close the handle returned by FileOpen. FileClose($hFileOpen) EndFunc #EndRegion Datos ###Equipo remoto### Link to comment Share on other sites More sharing options...
BrewManNH Posted March 16, 2017 Share Posted March 16, 2017 Nothing in your code that's placed after the While...Wend loop will ever get executed. So, none of the variables you have after it will get declared. You need to move that code elsewhere, either in a function or above the While loop. Also, if you move it to a function, do NOT use local for the declaration. It's a bad idea to use Local in a global scope because it's misleading to the casual coder. Local variables in a global scope are Global variables. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
rootx Posted March 17, 2017 Share Posted March 17, 2017 you have declared $aPCAlias as Local, then how can read anything your function _WritePCInfo() ? Link to comment Share on other sites More sharing options...
water Posted March 17, 2017 Share Posted March 17, 2017 BTW: When posting code please use AutoIt code tags in the editor (button "<>"). Makes your script much easier to read My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Rildoy Posted March 17, 2017 Author Share Posted March 17, 2017 Gracias pos sus respuestas. Pero he tratado de cambiar de orden el codigo y cambiar las variables a Local, pero me aparecen mas errores que antes. mi verdadero problema es que tengo 2 codigos distintos el, uno es el archivo "Box With Buttons" y el otro es "Info_PC. por favor como podria hacer para que el un boton delcodigo "Box With Buttons" llame al codigo "Info_PC". Desde ya muchas gracias, espero me comprendan ya que soy nuevo en AutoIT. Box with Buttons.au3 Info_PC.au3 Link to comment Share on other sites More sharing options...
Rildoy Posted March 17, 2017 Author Share Posted March 17, 2017 Thank you for your answers. But I tried to change the code and change the variables to Local, but I get more errors than before. My real problem is that I have 2 different codes, one is the file "Box With Buttons" and the other one is "Info_PC. Please, how could I do it so that the one button of the code" Box With Buttons "calls the code" Info_PC". From now on thank you very much, I hope you understand me since I am new to AutoIT. Info_PC.au3 Box with Buttons.au3 Link to comment Share on other sites More sharing options...
Danyfirex Posted March 17, 2017 Share Posted March 17, 2017 Hola. Y la información debería mostrarse en la ventana igual que el Código de Info PC.au3? Saludos PD: Este es un foro en ingles. Así que creo que deberías escribir en ingles. no al Español Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Rildoy Posted March 17, 2017 Author Share Posted March 17, 2017 The information should be displayed in the "Info_PC" window. I want to join those two codes, that the code "Box With Buttons" call "Info_PC" and the information is displayed in the same window of "Info_PC" that is the one that collects the information. 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