home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: InfoMgt / InfoMgt.zip / omnidemo.zip / RXASCIN.CMD < prev    next >
OS/2 REXX Batch file  |  1997-07-01  |  2KB  |  63 lines

  1. /* REXX PROGRAM */
  2. /* This REXX program expects Omnifile 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. FileIn = ARG(1)
  15. HeaderFile = ARG(2)
  16. Delimiter = ARG(3)
  17. RecType = ARG(4)
  18.  
  19. /* Make sure the required arguments where given. */
  20. IF FileIn = "" THEN DO
  21.     SAY "The following arguments are expected: FILEIN HEADERFILE DELIMITER"
  22.     SAY "    FILEIN is required."
  23.     SAY "    HEADERFILE will default to FILEIN if not given."
  24.     SAY "    DELIMITER will default to ',' if not given."
  25.     RETURN 1
  26.     END
  27. /* Set the default header file to the input file and the default delimiter to ','. */
  28. IF HeaderFile = "" THEN HeaderFile = FileIn
  29. IF Delimiter = "" THEN Delimiter = ','
  30. SetDefaultDelimiter(Delimiter)
  31.  
  32. /* If you want to override the RecType passed in, use the following format */
  33. /* RecType = GetTypeGivenName("Individual") */
  34. SetDefaultType(RecType)
  35.  
  36. /* Load the Header Line and pass it to Omnifile in order to initialize the import. */
  37. headerLine = LINEIN(HeaderFile)
  38. SetHeaderLine(headerLine)
  39.  
  40. /* For each line in the input file, load the line, loads the Rexx variables, modify the Rexx variables, and add the record. */
  41. DO while LINES(FileIn)
  42.     line = LINEIN(FileIn)
  43.     IF line == "" THEN ITERATE
  44.     Rec = GetRec(0, RecType)
  45.     SetRexxVariables(line)
  46.     CALL CHANGE_REXX_VARIABLES
  47.     SetRecFromRexxVariables()
  48.     AddRec()
  49.     end
  50. /* Close all the files. */
  51. result = stream(FileIn, 'c', 'close')
  52. IF HeaderFile \= FileIn THEN stream(HeaderFile, 'c', 'close')
  53. RETURN 0
  54.  
  55.  
  56. /* SUBROUTINE */
  57. CHANGE_REXX_VARIABLES:
  58. /* If necessary, change fields from a format suitable for import. */
  59. /* This subroutine is usually the only portion that the user needs to change. */
  60.  
  61. RETURN
  62.  
  63.