import ws.*;

// Example of using WTableList class on Passage Server

public class api_WTableList
{
  public WTableList Request(WServer oServer, WParamList oParamList)
  { 
    int n;
    WParamList oParamListRun;
    WTableList oTableList, oTableListRun;
    WTable     oTable, oTableRun;

    oTableList    = oServer.newTableList();
    oParamListRun = oServer.newParamList();
    oTable        = oServer.newTable();

    // There are two purposes of using WTableList:
    // 1. To add tables created in this request
    // 2. To get tables from running another request

    // 1. To add tables created in this request

    oTable.addCol(50);   // column 0
    oTable.addCol(100);  // column 1
    oTable.addCol(10);   // column 2
    oTable.addRow();     // row 0

    oTable.setField(0,0,"I");
    oTable.setField(0,1,"love");
    oTable.setField(0,2,"you");

    oTableList.add(oTable); // Add table 0

    // 2. To get table(s) from running another request

    // For example request "api_WTable" returns 1 table.
    oParamListRun.clear();
    //oParamListRun.add("param1");
    //oParamListRun.add("param2");
    //oParamListRun.add("...");
    oTableListRun = oServer.request("api_WTable", oParamListRun);
    if (oTableListRun.getEC() != 0)
      return oTableListRun;

    oTableRun = oTableListRun.get(0); // Get table 0

    oTableList.add(oTableRun); // Add table 1

    // This request returns 2 tables in oTableList - one created in this request and one received from another request.
    n = oTableList.size();

    return oTableList; 
  }
}