Here is the example:
- Code:
#class TTestClass //Class which will be stored in List.
public(
a$
);
public nproc Create
a$ = 100;
end;
public func getA()
return (a$);
end;
public proc setA(_a$)
a$ = _a$;
end;
public proc ShowA()
showMessage(str(getA()));
end;
#endClass
#class TPreTest //test with simple list of Objects
public(
l$
);
public nproc Create
list(l$);
for (i$, 0, count(args$) - 1)
add(l$, args$[i$]);
end;
end;
public proc ShowList()
s$ = "";
foreach (l$)
s$ += " " + str(l$);
end;
showMessage(s$);
end;
public proc TestObj()
last(l$);
TTestClass(p$);
&p;$ = l$;
p.showA();
end;
#endclass
#class TTest //Test with the list of arrays :(
public(
l$
);
public nproc Create
list(l$);
add(l$);
dim(l$, count(args$));
for (i$, 0, count(args$) - 1)
l$[i$] = args$[i$];
end;
end;
public proc ShowList()//shows the first elem of our list
s$ = "";
for (i$, 0, vmax(l$) - 1)
s$ += " " + str(l$[i$]);
end;
showMessage(s$);
end;
/*
Here we test the object in the list
(which is the list of arrays)
*/
public proc TestObj()
TTestClass(p$);
&p;$ = l$[vmax(l$) - 1];
p.showA();
end;
#endclass
proc Main
#object TTestClass inListObj$;
//simple test that works fine
inListObj.setA(40);
#object TPreTest obj$(1, 2, 3, inListObj$);
obj.ShowList();
inListObj.setA(80);
obj.TestObj();
//BUT... this way it doesnt work
inListObj.setA(40);
#object TTest obj1$(1, 2, 3, inListObj$);
obj1.ShowList();
inListObj.setA(80);
obj1.TestObj();
end;