cleararrayelements, multiple dimensions?

Started by Alex, May 13, 2007, 03:28:07 PM

Previous topic - Next topic

Alex

ok, it says in the help file that you can cleararrayelements with multiple dimensions..
how would i clear some elements in say the second dimension of an array?

kevin

#1
 
 When dealing with arrays you can pin point the elements/cells using what we refer to as the element address.  You can calc these by yourself (ok for single dimension arrays), or via wrapping the square bracket symbols around any array access. This tells the PB to return the element (cell) address.  (it's really an offset though)      These offset are uses to step through the data set of the array.  


PlayBASIC Code: [Select]
 Dim Table(10,20)


; -------------------------------------------
; fill first row of the array
;-------------------------------------------
For y=0 to 20
Table(0,y)=100+y
next

ShowArray(Table())


; -------------------------------------------
; calc the Step direction
; -------------------------------------------
Delta=[Table(0,1)]
For x=0 to 10
CopyArrayCells Table(),[Table(0,0)],Delta,Table(),[table(x,0)],delta,21
next


ShowArray(Table())


; -------------------------------------------
; Clear somes columns
; -------------------------------------------

; calc the Step direction (Down the array)
Delta=[Table(1,0)]
FillValue=0
for x=4 to 6
ClearArrayCells Table(),[Table(0,x)],Delta,11 ,FillValue
next


ShowArray(Table())


Sync
waitkey



Function ShowArray(me())
Print "Array Contents"

For x=0 to GetArrayElements(me(),1)
s$=""
For y=0 to GetArrayElements(me(),2)
s$=s$+STR$(me(x,y))+","
next
print TrimRight$(s$,",")
next
print ""
EndFunction





Alex

nice!
thanks, I didn't realize you could do this.

managed to clear some arrayelements with this. now im wondering what other applications there could be with this [] bracket thing. I'll assume it'll come in handy.