GetArray

PowerBuilder Native Interface

PBBoundedArrayCreator template class:

GetArray method

Description

Syntax

GetArray()

Return Values

Examples

LPCTSTR *ostr_a;
char **sp;
int i;
pbarray out_array;
arrayBounds* bounds;
pbuint dim1, dim2, current_dim;
pblong itemcount1, itemcount2;
PBXRESULT ret;
PBArrayInfo* ai;
pbstring *iarg, *oarg;
typedef PBBoundedArrayCreator<pbvalue_string>
   BoundedStringArrayCreator;
in >> dim1;
// allocate memory for pointer bounds
bounds = (arrayBounds*)malloc(dim1*sizeof
   (PBArrayInfo::ArrayBound));
bounds = new arrayBounds[dim1];
// read in lowerbound and upperbound for each dimension
// and calculate the array item count
itemcount1 = 1;
for (i=0;i<dim1;i++)
{
  in >> bounds[i].lowerBound >> bounds[i].upperBound;
  itemcount1 = itemcount1*
    (bounds[i].upperBound - bounds[i].lowerBound +1);
}
sp = new char*[itemcount1];
ostr_a = new LPCTSTR[itemcount1];
iarg = new pbstring[itemcount1];
// Read in array items
for (i=0; i<itemcount1; i++)
{
  sp[i] = new char[20];
  in >> sp[i];
  iarg[i]= session->NewString(sp[i]);
}
// create bounded simple array and set iarg[i] to it
{
  BoundedStringArrayCreator ac(session, dim1, bounds);
  current_dim = 1;
  BoundedArrayItem<pbstring, pbvalue_string,
       BoundedStringArrayCreator>::f_set_arrayitem
       (session, ac, dim1, bounds, iarg, current_dim);
  BoundedArrayItem<pbstring, pbvalue_string,
      BoundedStringArrayCreator>::array_itemcount = 0;
  out_array = ac.GetArray();
}

See Also