Skip to content

Version 13 Revision 51

Choose a tag to compare

@M2000Interpreter M2000Interpreter released this 20 May 23:05
· 169 commits to main since this release

MD5 c056d3135e5f24a32925450317bc927a

We can make arrays of objects (of type RefArray) using for object of type aa: aa k[2] or aa k[2][20] or we can make more dimensions making an object array which get for each element another array.
Also we can do that inside another object, type beta, which have private the class aa, and private k (as pointer to refarray) or at the second example the array k() (see parenthesis, is an mArray type), here we have from 0 to 10 dimensions.

  1. Using RefArray type of array (using [ ])
class beta {
private:
	class aa {
		x=10&
	}
	aa k[2][20]
public:	
	module that {
		.k[2][3].x++
		? .k[2][3].x,  "k[2][3].x"
		.k[2][7].x*=100
		? .k[2][7].x
		for i=0 to len(.k)-1
			print i, .k[2][i].x
		next
		list
	}
}
beta z[4]   ' 5 times same object
' so we change the last 4 with new one
' so we get new k[][] array (is a pointer type array)
for i=1 to 4:z[i]=beta():next
z[1].that
Z[2].that
Z[2].that

  1. Using Array of objects (of type mArray)
global counter=0
class beta {
private:
	class aa {
		a=0&
		x=10&
	class:
		module aa {
			counter++
			.a<=counter
		}
	}
	dim k() as object
public:	
	module that {
		.k(2,3).x++
		? .k(2,3).x , "k(2,3).x", .k(2,3).a
		.k(2,7).x*=100
		? .k(2,7).x
		for i=0 to dimension(.k(),1)-1
			print i, .k(2,i).x
		next
		list
	}
class:
	module beta {
		dim .k(0 to 2, 0 to 20)<<.aa()
	}
}
rem {   ' uncomment this block, press enter after rem 
	beta z[4]   ' 5 times same object
	rem : 
	for i=1 to 4:z[i]=beta():next   ' comment this line to see the difference.
	? counter
	z[1].that
	Z[2].that
	Z[2].that
	break
}

dim z(0 to 4)<<beta()
? counter
z(1).that
Z(2).that
Z(2).that

See documentation (English/Greek) from release: Version 13 Revision 44