anixon Posted September 20, 2007 Share Posted September 20, 2007 After displaying an 2 dimension array like: _arraydisplay($array) [0] 3 [1] "text1" [2] "text2" [3] "Text3" How do I then clear all the contents of the array so that if it was displayed again it would look like _arraydisplay($array) [0] 0 is there a single command or do you have to use _arraydelete($array) in a loop and uBound to set [0] to 0 Help is always appreciated Ant.. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 20, 2007 Moderators Share Posted September 20, 2007 (edited) After displaying an 2 dimension array like: _arraydisplay($array) [0] 3 [1] "text1" [2] "text2" [3] "Text3" How do I then clear all the contents of the array so that if it was displayed again it would look like _arraydisplay($array) [0] 0 is there a single command or do you have to use _arraydelete($array) in a loop and uBound to set [0] to 0 Help is always appreciated Ant..1. That's an example of a 1 dimensional array, not a 2. 2. You'd have to write the condition I suppose lol... I personally wouldn't have [0] = anything. This example should clear up to a 4 dimensional array:Func _ClearArray(ByRef $avArray) Switch UBound($avArray, 0) Case 1 ReDim $avArray[UBound($avArray)] Case 2 ReDim $avArray[UBound($avArray, 1)][UBound($avArray, 2)] Case 3 ReDim $avArray[UBound($avArray, 1)][UBound($avArray, 2)] _ [UBound($avArray, 3)] Case 4 ReDim $avArray[UBound($avArray, 1)][UBound($avArray, 2)] _ [UBound($avArray, 3)][UBound($avArray, 4)] Case Else Return SetError(1, 0, 0) EndSwitch Return 1 EndFunc Edited September 20, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
enaiman Posted September 20, 2007 Share Posted September 20, 2007 A simple Dim $array will do the trick. When using Dim it will set the new UBound and clear the values. Here is a small example: #include <array.au3> Dim $array[3] $array[0]=2 $array[1]=15 $array[2]=66 _ArrayDisplay($array) Dim $array[1] $array[0] = 0 _ArrayDisplay($array) 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 :) Link to comment Share on other sites More sharing options...
anixon Posted September 20, 2007 Author Share Posted September 20, 2007 A simple Dim $array will do the trick. When using Dim it will set the new UBound and clear the values. Here is a small example: #include <array.au3> Dim $array[3] $array[0]=2 $array[1]=15 $array[2]=66 _ArrayDisplay($array) Dim $array[1] $array[0] = 0 _ArrayDisplay($array) Thanks for that works perfectly. Ant.. 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