PBArrayAccessor template class:
SetAt method
Description
Sets the array item at the specified dimension.
Syntax
For arrays of a specified ValueType:
1 |
SetAt(pblong <span>dim</span>[ ], ValueType <span>v</span>) |
For string arrays:
1 |
SetAt(pblong <span>dim</span>[ ], LPCTSTR <span>string</span><span></span>) |
1 |
SetAt(pblong <span>dim</span>[ ], pbstring <span>string</span><span></span>) |
Argument |
Description |
---|---|
dim |
The dimension of the array item to be |
v |
A ValueType defined in pbtraits.h |
string |
A string of type pbstring or LPCTSTR |
Return Values
None.
Examples
This example shows the use of GetAt and SetAt in
arrays of a type specified by a ValueType:
1 |
template < typename T, pbvalue_type I><br>void ArrayCreator<T, I>::f_unbounded_simple_array(<br>   IPB_Session* session,<br>   ifstream in,<br>   fstream out,<br>   LPCSTR data_type)<br>{<br>  pbarray out_array;<br>  int i;<br>  pblong dim[4], itemcount1, itemcount2;<br> <br>  T *iarg, oarg;<br> <br>  in >> itemcount1;<br>  iarg = new T[itemcount1];<br>// Create unbounded integer array <br>  {<br>   PBUnboundedArrayCreator<I> ac(session); <br>   out_array = ac.<span>GetArray</span>();<br>   PBArrayAccessor<I> aa(session, out_array);<br>   for(i=0; i<itemcount1; i++)<br>      in >> iarg[i];<br>   for (i=0; i<itemcount1; i++)<br>   {<br>     dim[0]=i+1;<br>     aa.<span>SetAt</span>(dim, iarg[i]);<br>   }<br>   itemcount2 = session->GetArrayItemCount(out_array); <br>   out <<"The array item count is "<< itemcount2 <<<br>      endl; <br>   for (i=0; i<itemcount2; i++)<br>   {<br>    dim[0]=i+1;<br>    oarg=aa.<span>GetAt</span>(dim);<br>    if (oarg != iarg[i])<br>     out << "*** ERROR"<< endl;<br>    else<br>     out << oarg << " ";<br>   }<br>  }<br>  delete []iarg;<br>  out << endl; <br>  return;<br>} |
See Also
Document get from Powerbuilder help
Thank you for watching.
Subscribe
Login
0 Comments