home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / xactus.zip / macros / readsp.xc$ / xsmp32 / os2 / uk / readsp.xcd
Text File  |  1994-09-29  |  2KB  |  61 lines

  1. /*************************************************************************
  2.  * Xact macro
  3.  * 
  4.  *************************************************************************/
  5. Parse Arg handle
  6.  
  7.     Say "This macro opens an existing table and copies any lines that "||,
  8.     "meet certain criteria into a new table."
  9.  
  10.     tHandle1 = XR_OpenTab("TABLES\STATES.XTF")    /* Open a table */
  11.     tHandle2 = XR_OpenTab()                       /* Create a new table */
  12.  
  13.     totalCols = XR_NumOfColumns(tHandle1)         /* Number of columns */
  14.     totalLines = XR_NumOfLines(tHandle1)          /* Number of lines */
  15.  
  16.     Call getRowValues tHandle1, 0, totalCols      /* read line 0      */
  17.     Call setRowValues tHandle2, 0, totalCols      /* write line 0 */
  18.  
  19.     wi = 1                                        /* counter for written lines */
  20.  
  21.     Do  ri = 1 To totalLines
  22.         If XR_ReadCell(tHandle1, ri, 3) = 'w' Then Do    /* check cell     */
  23.             Call getRowValues tHandle1, ri, totalCols    /* read the line  */
  24.             Call setRowValues tHandle2, wi, totalCols    /* write the line */
  25.             wi = wi + 1
  26.         End
  27.     End
  28.  
  29. Return
  30.  
  31.  
  32. /*************************************************************************
  33.  * getRowValues
  34.  *
  35.  * Read all cells of line 'rowNo' from the window 'handle'
  36.  *************************************************************************/
  37.  
  38. getRowValues: procedure expose row.
  39.     Parse Arg handle, rowNo, total
  40.  
  41.     Do  i = 0 To total
  42.         row.i = XR_ReadCell(handle, rowNo, i)
  43.     end
  44. Return
  45.  
  46.  
  47. /*************************************************************************
  48.  * setRowValues
  49.  *
  50.  * Write all cells of line 'rowNo' to the window 'handle'
  51.  *************************************************************************/
  52.  
  53. setRowValues: procedure expose row.
  54.     Parse Arg window, rowNo, total
  55.  
  56.     Do  i = 0 To total
  57.         Call XR_WriteCell window, rowNo, i, row.i
  58.     end
  59. Return
  60.  
  61.