Emiel Wieldraaijer Posted December 31, 2007 Posted December 31, 2007 Hi All, #include <Array.au3> Dim $avArray $avArray = _ArrayCreate("JPM", "Holger", "Jon", "Larry", "Jeremy", "Valik", "Cyberslug", "Nutster", "Tylo", "JdeB") msgbox (0, "Count this array ?", $avArray[0]) Exit Shouldn't $avArray[0] return the amount of items in the array ? Thnx Emiel Best regards,Emiel Wieldraaijer
BrettF Posted December 31, 2007 Posted December 31, 2007 No. Only functions that return the number in $array[0] will return that. Otherwise it is the first element of the array. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
MHz Posted December 31, 2007 Posted December 31, 2007 Hi Emiel, Shouldn't $avArray[0] return the amount of items in the array ?No specification or standard states that _ArrayCreate() should use the 1st element as a count of total elements. _ArrayCreate() predates the newer syntax of array creation so you may like to use it instead. Global $avArray[11] = [10, "JPM", "Holger", "Jon", "Larry", "Jeremy", _ "Valik", "Cyberslug", "Nutster", "Tylo", "JdeB"] For $i = 0 To $avArray[0] MsgBox(0, $i, $avArray[$i], 1) Next
Emiel Wieldraaijer Posted December 31, 2007 Author Posted December 31, 2007 (edited) Hi Bert and Mhz, thnx Mhz this is not a solution to me maybe there is another solution to my problem Global $wbemFlagReturnImmediately = 0x10 Global $wbemFlagForwardOnly = 0x20 Global $wbemFlags = $wbemFlagReturnImmediately + $wbemFlagForwardOnly Global $strComputer = @ComputerName Global $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Global $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlags) i want to create an array of $objItem.LoadPercentage, can this be done ? where $Array[0] is the amount of values Thnx Emiel Edited December 31, 2007 by Emiel Wieldraaijer Best regards,Emiel Wieldraaijer
JerryD Posted December 31, 2007 Posted December 31, 2007 #include <array.au3> Const $wbemFlagReturnImmediately = 0x10 Const $wbemFlagForwardOnly = 0x20 Const $strComputer = 'localhost' Dim $RetAry[1] $RetAry[0] = 0 $objWMIService = ObjGet('winmgmts:\\' & $strComputer & '\root\CIMV2') $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_Processor', 'WQL', $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems ReDim $RetAry[$RetAry[0]+2] $RetAry[0] += 1 $RetAry[$RetAry[0]] = $objItem.LoadPercentage Next _ArrayDisplay ( $RetAry ) Else MsgBox(0, 'WMI Output', 'No WMI Objects Found for class: ' & 'Win32_Processor') EndIf
Emiel Wieldraaijer Posted December 31, 2007 Author Posted December 31, 2007 @JerryD Thnx exactly what i needed .. Best regards, Emiel Best regards,Emiel Wieldraaijer
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