Slice Arrays

BlitzMax Forums/BlitzMax Programming/Slice Arrays

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

yes
' arrays
Graphics 800,600,0

Local myarray:String[]=["fe","fi","fo","fum"]

Original$ = " Myarray consists of  "+Len(myarray)+" elements: "

For foo$ = EachIn myarray
	cnt = cnt + 1
	If cnt>1 Then original$ = original$ + " , "
	original$ = original$ + foo$
	
next
cnt = 0
myarray = myarray[..2]
sliced$ = " New (sliced) Myarray consists of "+Len(myarray)+" elements: "
For foo$ = EachIn myarray
	cnt = cnt + 1
	If cnt>1 Then sliced$ = sliced$ + " , "
	sliced$ = sliced$ + foo$
	
Next

DrawText (original,10,10) 
Print original
DrawText (sliced,10,30)
Print sliced
flip

waitmouse


result:
Myarray consists of 4 elements: fe , fi , fo , fum
New (sliced) Myarray consists of 2 elements: fe , fi