Using the IPB_Session interface

The IPB_Session interface is an abstract interface that enables the PBVM to interact with PowerBuilder extensions and with external applications. It defines hundreds of methods for accessing PowerScript variables, calling PowerScript methods, handling exceptions, and setting a marshaler to convert PowerBuilder data formats to the user's communication protocol.

The IPB_Session interface includes several categories of methods:

  • Class accessor methods are used to find PowerBuilder classes, call PowerBuilder methods and events, and get and set instance variables of PowerBuilder objects.

  • Exception-handling methods communicate with the PowerBuilder exception handling mechanism.

  • Array accessor methods create and access PowerBuilder bounded and unbounded arrays.

  • Result set accessor methods work with result sets in DataStores and DataWindow controls.

  • Typed data access methods create and access data of the PowerBuilder types string, double, decimal, blob, date, time, datetime, and so forth.

  • Proxy access methods provide an interface for the implementation of new protocols.

  • The Release method releases the IPB_Session object itself.

For a complete list of methods, see IPB_Session interface.

You use IPB_Session methods in conjunction with IPB_Value and IPB_Arguments methods.

The following code fragment shows the body of a method that tests whether a date passed to a PBNI function is handled correctly by a PowerBuilder function. It uses the IPB_Value SetToNull, SetDate, and IsNull methods to set and test the date values in the PBCallInfo structure, as well as the IPB_Session SplitDate, SetDate, and NewDate methods.

// boolean isNull[], pbobject myobj, 
// and pbdate* d_date arguments passed in
pbclass cls;
pbmethodID mid;
PBCallInfo* ci = new PBCallInfo;
pbdate ret_date;
pbint yy,mm,dd;

cls = Session-> GetClass(myobj);
mid = Session-> GetMethodID(cls,"uf_getdate_byref",
      PBRT_FUNCTION,"YR");
Session-> InitCallInfo(cls, mid, ci);

if (isNull[0]) 
   ci -> pArgs -> GetAt(0)->SetToNull();
else
         ci-> pArgs -> GetAt(0) ->SetDate(*d_date);

Session->InvokeObjectFunction(myobj, mid, ci);

Session->SplitDate(ci->pArgs->GetAt(0)->GetDate(),
   &yy,&mm,&dd); 
Session->SetDate(*d_date, yy, mm, dd); 

if (ci-> returnValue ->IsNull())
{
   ret_date = Session-> NewDate();
   Session-> SetDate(ret_val, 1900, 1, 1);
}
else
{
   ret_date = Session-> NewDate();
   Session -> SplitDate(ci-> returnValue -> GetDate(),
      &yy,&mm,&dd); 
   Session -> SetDate(ret_val,yy,mm,dd);
}
Session -> FreeCallInfo(ci);
delete ci;
return ret_date;