home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 November / PCO_1198.ISO / filesbbs / os2 / os2www.arj / OS2WWW.ZIP / SYS406.R8 / TOUR / SOURCE / REXXCSV.TXT next >
Encoding:
Text File  |  1995-11-10  |  1.7 KB  |  66 lines

  1. /*******************************************************************************
  2. *
  3. * This module presents example PowerWeb Server++ API Hook Functions.
  4. *
  5. *    Implements the same functionality as the C-language TourPresentCSV API hook.
  6. *
  7. *    The two implementations are plug-in replaceable, showing how a
  8. *    customised extension can be rapidly prototyped in Rexx and then either
  9. *    used as-is, or ported across to C for final production release.
  10. *
  11. * COPYRIGHT:
  12. *   CompuSource (Pty) Ltd
  13. *   Licensed Materials - Property of CompuSource (Pty) Ltd
  14. *   (C) Copyright CompuSource (Pty) Ltd 1994, 1995.
  15. *   All Rights Reserved
  16. *   Use, duplication, or disclosure restricted by international
  17. *   copyright law.
  18. *
  19. *******************************************************************************/
  20.  
  21. Parse Arg parcel
  22.  
  23. filename = ServerReadText(parcel, "Request:/Resource") 
  24.  
  25. html = ServerFind(parcel, "Request:/Result")
  26.  
  27. call ServerAppendText html,, "<html><body><h2>Tabular View of " filename "</h2><table border=1>"
  28.  
  29. /* open the file */
  30. call stream filename, 'C', 'open read'
  31.  
  32.     /* read the file line by line */
  33.  
  34.     do while lines(filename)    
  35.  
  36.         record = linein(filename)
  37.  
  38.         call ServerAppendText html,, "<tr>"
  39.     
  40.         /* process each field, separated by commas */
  41.  
  42.         do while length(record) > 0
  43.  
  44.             parse var record field ',' record
  45.  
  46.             /* if field is enclosed in quotes, remove them */
  47.  
  48.             if substr(field,1,1) = '"' then do
  49.                 if substr(field, length(field), 1) = '"' then
  50.                     field = substr(field, 2, length(field)-2)
  51.             end
  52.  
  53.             /* add the field to the table */
  54.  
  55.             call ServerAppendText html,, "<td>"field
  56.         end
  57.     end
  58.  
  59. /* close the file */
  60. call stream filename, 'C', 'close'
  61.  
  62. call ServerAppendText html,, "</table></body></html>"
  63.  
  64. return "0"
  65.  
  66.