Jump to content
Sign in to follow this  

Easy Question, is there a _ArrayCreate or Dim $array[0]?

Recommended Posts


If I want to make a dynamic array (which I use A LOT), I have to do this:

Dim $array[1] ;Makes an array with an empty spot in it... Because I can't use $array[0] or just $array




_ArrayDelete($array,0 ;To delete the empty spot I made.

Is there any way to do this...?



So that I don't always have to delete that empty spot in the array?


Share this post

Link to post
Share on other sites

Use your custom ArrayAdd function: example:

Func _Array0Add(ByRef $avArray, $vValue)
    If Not IsArray($avArray) Then Return SetError(1, 0, -1)
    If UBound($avArray, 0) <> 1 Then Return SetError(2, 0, -1)

    Local $iUBound = UBound($avArray)
    If $iUBound = 1 And $avArray[0] = 0 Then
        $avArray[0] = $vValue
        ReDim $avArray[$iUBound + 1]
        $avArray[$iUBound] = $vValue
    Return $iUBound
EndFunc  ;==>_Array0Add

This function will replace element 0 with the $vValue if the array has a single element and its value is 0

IMO - you better use $array[0] = "blah" instead of



SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.