Sign in to follow this  
Followers 0
SoulBlade

Problem with a simple array

4 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks you very much for your answers!

I'll will try to improve my knowledge on arrays.

:D

Edited by SoulBlade

Share this post


Link to post
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
Sign in to follow this  
Followers 0