home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: InfoMgt / InfoMgt.zip / omnifile.zip / RXASCOUT.CMD < prev    next >
OS/2 REXX Batch file  |  1998-02-04  |  2KB  |  67 lines

  1. /* REXX PROGRAM */
  2. /* This REXX program expects Omnifile or CCv2 to be the host environment */
  3. /* If you are attempting to change this file, you will normally only need to change the command in the CHANGE_REXX_VARIABLES subroutine. */
  4.  
  5.  
  6. /* MAIN SUBROUTINE */
  7. szEnvironment = address()
  8. IF ((szEnvironment <> "Omnifile") & (szEnvironment <> "Contacts")) THEN DO
  9.     SAY "This rexx file can only be run by Omnifile or Contact Connection, not directly."
  10.     RETURN 1
  11.     END
  12.  
  13. /* Load the Rexx variables based on the arguments the user passed in. */
  14. FileOut = ARG(1)
  15. HeaderFile = ARG(2)
  16. Delimiter = ARG(3)
  17. QuoteFields = ARG(4)
  18. AddHeaderLine = ARG(5)
  19.  
  20. /* Make sure the required arguments where given. */
  21. IF FileOut = "" THEN DO
  22.     SAY "The following arguments are expected: FILEOUT HEADERFILE DELIMITER"
  23.     SAY "    FILEOUT is required."
  24.     SAY "    HEADERFILE will default to FILEOUT if not given."
  25.     SAY "    DELIMITER will default to ',' if not given."
  26.     SAY "    'QuoteFields' - optional argument to quote each field"
  27.     SAY "    'AddHeaderLine' - optional argument to add header line to output file"
  28.     RETURN 1
  29.     END
  30. /* Set the default header file to the output file and the default delimiter to ','. */
  31. IF HeaderFile = "" THEN HeaderFile = FileOut
  32. IF Delimiter = "" THEN Delimiter = ','
  33. SetDefaultDelimiter(Delimiter)
  34.  
  35. /* Load the Header Line and pass it to Omnifile in order to initialize the import. */
  36. HeaderLine = LINEIN(HeaderFile)
  37. SetHeaderLine(HeaderLine)
  38. Say "AddHeaderLine = "AddHeaderLine
  39. IF (AddHeaderLine \= "") & (HeaderFile \= FileOut) THEN DO
  40.     LINEOUT(FileOut, HeaderLine)
  41.     END
  42.  
  43. /* Get each matching record and output it */
  44. Rec = GetRec("First")
  45. DO WHILE Rec \= 0
  46.     SAY "Now writing rec# "Rec
  47.     Result = SetRexxVariablesFromRec(Rec)
  48.     CALL CHANGE_REXX_VARIABLES
  49.     Line = MakeOutputLine(QuoteFields)
  50.     LINEOUT(FileOut, Line)
  51.     Rec = GetRec("Next")
  52.     END
  53.  
  54. /* Close all the files. */
  55. Result = stream(FileOut, 'c', 'close')
  56. IF HeaderFile \= FileOut THEN stream(HeaderFile, 'c', 'close')
  57. RETURN 0
  58.  
  59.  
  60. /* SUBROUTINE */
  61. CHANGE_REXX_VARIABLES:
  62. /* If necessary, change fields from a format suitable for import. */
  63. /* This subroutine is usually the only portion that the user needs to change. */
  64.  
  65. RETURN
  66.  
  67.