pmahesha
13 years agoOccasional Contributor
Array of Class Objects
I would like to know how to create an array of class type.
I have defined ODT class named "TextFieldClass" with two properties property1 and property2
To create an object of this class, I use ODT.Classes.New(" TextFieldClass");
Then I initialize each class items.
Ex:
myObj=ODT.Classes.New(" TextFieldClass");
myObj.property1="My Name";
myObj.property2="My Address";
But I want to create an array of type TextFieldClass. I could not find a direct method. I used indirect method:
var myArrayObj= new Array();
// Create 5 objects of TextFieldClass type
for(var count=0;count<5;count++)
{
myArrayObj[count]=ODT.Classes.New(" TextFieldClass");
}
// Now initialize individual elements as required.
myArray[0].property1= "Name1";
myArray[0].property2' "Address1"
myArray[1].property1= "Name2";
myArray[1].property2' "Address2"
Though this worked fine, I want to know if we have any direct way of defining array of objects something like:
var myArrayObj=new Array(ODT.Classes.New(" TextFieldClass"));
Alternate method could be (I did not try) to create another class and define new arrayObject of first type inside this second class!!!
(Note: Above code may have few errors, it is not compiled one. Only shows the concept)
I have defined ODT class named "TextFieldClass" with two properties property1 and property2
To create an object of this class, I use ODT.Classes.New(" TextFieldClass");
Then I initialize each class items.
Ex:
myObj=ODT.Classes.New(" TextFieldClass");
myObj.property1="My Name";
myObj.property2="My Address";
But I want to create an array of type TextFieldClass. I could not find a direct method. I used indirect method:
var myArrayObj= new Array();
// Create 5 objects of TextFieldClass type
for(var count=0;count<5;count++)
{
myArrayObj[count]=ODT.Classes.New(" TextFieldClass");
}
// Now initialize individual elements as required.
myArray[0].property1= "Name1";
myArray[0].property2' "Address1"
myArray[1].property1= "Name2";
myArray[1].property2' "Address2"
Though this worked fine, I want to know if we have any direct way of defining array of objects something like:
var myArrayObj=new Array(ODT.Classes.New(" TextFieldClass"));
Alternate method could be (I did not try) to create another class and define new arrayObject of first type inside this second class!!!
(Note: Above code may have few errors, it is not compiled one. Only shows the concept)