Selection of and access to parts Vectors How to build a VECTORobject

How to build a VECTORobject

Let us first look at an example for the construction of a VECTORobject:
#include "def.h"
#include "macro.h"
main()
{
OP\ v;
anfang();
v = callocobject();
m_il_v(8L,v);
println(v);
freeall(v);
ende();
}

The routine m_il_v() builds an VECTORobject with eight empty objects. The output will be

[#,#,#,#,#,#,#,#]

The complete description follows

There is the routine/macro

b_il_v, B_IL_V
which is the same. There is also the routine, where you enter an INTEGERobject, and you will get a VECTORobject with this length. See the following example:
...
scan(INTEGER,a);
b_l_v(a,b);
println(b);
...
Here the INTEGERobject a becomes the length part of the VECTORobject b, and so, if you delete the VECTORobject using freeall(), or freeself(), you can no longer access the INTEGERobject a, because it was freed as part of the VECTORobject b. If you want to avoid this, you have to use the make-constructor, which does a copy:
...
scan(INTEGER,a);
m_l_v(a,b);
println(b);
...
Here you can free the VECTORobject b, and you have still an INTEGERobject a. This method is easier for you, but you need more memory for data. Now we are ready for the complete description of these two routines There are the special cases, where you have one object and you want to build a vector, whose single component is this object: These are the routines for the construction of VECTORobjects, now we come to routines for the selection of parts.
harald.fripertinger "at" uni-graz.at, May 26, 2011

Selection of and access to parts Vectors Uni-Graz Mathematik How to build a VECTORobject Valid HTML 4.0 Transitional Valid CSS!