Namespace myapp
 
#Import "<std>"
 
Using std..
 
Function resize2<T>:T[,](source:T[,],x:Int,y:Int)
	Local dest := New T[x,y]
	
	For Local i:Int = 0 Until Min(source.GetSize(0),dest.GetSize(0))
		For Local j:Int = 0 Until Min(source.GetSize(1),dest.GetSize(1))
			dest[i,j] = source[i,j]
		Next
	Next
	Return dest
end
 
Function Main()
	
	'create array and fill with random data
	Local test:String[,] = New String[5,5]
	For Local x:Int = 0 To 4
		For Local y:Int = 0 To 4
			test[x,y] = String.FromChar(Rnd(26)+65)
		Next
	next
 
 
	printArray(test)
	
	'increase array size
	test = resize2(test,10,10)
	
	printArray(test)
	
	'decrease array size
	test = resize2(test,7,7)
	
	printArray(test)
	
	'increase one dimention, decrease another
	test = resize2(test,10,3)
	
	printArray(test)
	
End
 
Function printArray(source:String[,])
	Print "-----------------------------------------~n"
	For Local y:Int = 0 Until source.GetSize(1)
		Local s:String = ""
		For Local x:Int = 0 Until source.GetSize(0)
			If Not source[x,y]
				s += "# "
			Else
				s += source[x,y] + " "
			Endif
		Next
		Print s
	Next
	Print "~n----------------------------------------"
end