Jump to content

Problem with a simple array


Recommended Posts

Hi!

I'm trying to create a simple array but unfortunately my knowledge is lacking.

In this script i try to output the list of installed disks from WMI to an array.

Can anyone point me in the right direction?

Thanks!

dim $hds

MsgBox(-1,"",$hds[1])

Func HD()
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $strComputer = "."
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
    $Instances = $objWMIService.InstancesOf("Win32_DiskDrive")
    For $hd In $Instances
    
        $hds = ($hd.Model)
    
            Next
EndFunc
Link to comment
Share on other sites

Dim $array[10]

For $i = 0 To 9 Step 1
    $array[$i] = $i
Next

MsgBox(0,'',$array[0]&","&$array[1]&","&$array[2]&"..."&$array[9])

dim a vairable as array 1st

Edited by Belfigor

[size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size]

Link to comment
Share on other sites

#include <array.au3>

dim $hds

$hds = HD()

_ArrayDisplay($hds)

Func HD()
    Local $return[1], $i = 1
    $return[0] = 0

    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $strComputer = "."
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
    $Instances = $objWMIService.InstancesOf("Win32_DiskDrive")
    For $hd In $Instances
        Redim $return[Ubound($return) + 1]
        $return[0] = $return[0] + 1

        $return[$i] = $hd.Model
        $i += 1
    Next

    Return $return
EndFunc

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...