home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 15a / convdb2.zip / CONV.CMD < prev   
OS/2 REXX Batch file  |  1987-02-14  |  5KB  |  136 lines

  1.  
  2. ************************************************************
  3. ************************************************************
  4. *****  con.cmd     File Converter  (c) COPYRIGHT 1983  *****
  5. *****                              Data Based Advisor  *****
  6. *****                                                  *****
  7. *****  AUTHOR: Larry Eitel                             *****
  8. *****  DATE: October 29, 1983                          *****
  9. *****                                                  *****
  10. *****  PURPOSE:                                        *****
  11. *****  This program is used to transfer the contents   *****
  12. *****  of one file to another file with a different    *****
  13. *****  structure.  Throughout the program variables    ***** 
  14. *****  will be prefaced with the phrase "from" which   *****
  15. *****  denotes information from the file that will be  *****
  16. *****  converted and added to the "to" file.  If the   *****
  17. *****  program is run through completion, the file     *****
  18. *****  that will recieve the converted information     *****
  19. *****  will be in the PRIMARY use area, and the other  *****
  20. *****  file will be in the SECONDARY use area.         *****
  21. *****                                                  *****
  22. *****  DISCLAIMER:                                     *****
  23. *****  The author makes or implies no warranties       *****
  24. *****  regarding the operation or usefulness of this   *****
  25. *****  program.  It is recommended the user make       *****
  26. *****                                                  *****
  27. *****  NOTE TO 16-bit USERS:                           *****
  28. *****  This program is compatable for 16-bit machines. *****
  29. *****  One exception is that the command file          *****
  30. *****  extention must be renamed from .CMD to .PRG.    *****
  31. ************************************************************
  32. ************************************************************
  33. CLEAR
  34. SET talk OFF
  35. DO WHILE t
  36.   ERASE
  37.   STORE '* * * * * * File Converter  (c) COPYRIGHT 1983 '+;
  38.   'Data Based Solutions * * * * * *' TO header
  39.   ? header
  40.   ***** Get the file to append to and the file to append 
  41.   ***** from
  42.   DO confile
  43.   ***** Open the file to append to
  44.   USE &tock
  45.   SELECT seco
  46.   ***** Open the file to append from 
  47.   USE &fromck
  48.   ***** Create a temporary file to be used later to check
  49.   ***** for valid REPLACE statements.
  50.   COPY STRUCTURE TO temp.$$$
  51.   USE temp.$$$
  52.   APPEND BLANK
  53.   ***** number and lnumber is used to create and display 
  54.   ***** individual REPLACE statements
  55.   STORE 1 TO number
  56.   STORE str(number,1) TO lnumber
  57.   ERASE
  58.   @ 03,03 SAY '================[  INSTRUCTIONS  ]================'
  59.   @ 05,03 SAY '1)  Enter your replacement statements.'
  60.   @ 06,03 SAY '2)  Display replacement statements if you like.'
  61.   @ 07,03 SAY '3)  Generate CONVERT program.'
  62.   @ 08,03 SAY '4)  Run CONVERT program.'
  63.   @ 10,03 SAY 'NOTE:' 
  64.   @ 11,06 SAY 'If you are converting <FILE1> into <FILE2> and'
  65.   @ 12,06 SAY 'you have field names that are the same in each'
  66.   @ 13,06 SAY 'file, you must put a P. (for primary) or a S.'
  67.   @ 14,06 SAY '(for secondary) in front of the field names'
  68.   @ 15,06 SAY 'that you want to use (P.NAME  S.ADDRESS).'
  69.   @ 16,06 SAY 'The file you are converting TO is the PRIMARY'
  70.   @ 17,06 SAY 'file - and the file you are converting FROM'
  71.   @ 18,06 SAY 'is the SECONDARY file.'
  72.   @ 20,00 SAY 'Press any key to CONTINUE'
  73.   WAIT
  74.   ***** This loop is for entering and displaying REPLACE 
  75.   ***** statements and generating a command file.
  76.   STORE t TO generate
  77.   DO WHILE generate
  78.     ERASE
  79.     ? header
  80.     STORE ' ' TO choice
  81.     @ 3,0 SAY 'Convert the contents in the file ' +;
  82.     trim(fromck)+' and add to the file ' +trim(tock)+ '.' 
  83.     ***** Enter choice of options
  84.     @ 5,0 SAY 'Now you may (D)isplay replace statements, ' +;
  85.     '(E)nter replace statements,' 
  86.     @ 6,0 SAY '(G)enerate CONVERT.CMD, (R)un CONVERT.CMD '+;
  87.     'or <RET> to Exit. ' GET choice
  88.     READ
  89.     DO CASE
  90.       CASE choice= ' ' 
  91.         STORE f TO generate
  92.         LOOP
  93.       CASE !(choice)= 'D' 
  94.         @ 8,0 SAY ' ' 
  95.         STORE 1 TO showline
  96.         STORE str(showline,1) TO show
  97.         ***** Display any REPLACE statements 
  98.         DO WHILE 0#test(line&show)
  99.           ? line&show
  100.           STORE showline+1 TO showline
  101.           IF showline<10
  102.             STORE str(showline,1) TO show
  103.           ELSE
  104.             STORE str(showline,2) TO show
  105.           ENDIF showline<10 
  106.         ENDDO WHILE 0#test(line&show) 
  107.         ?
  108.         ? 'Press any key to continue.' 
  109.         WAIT
  110.         LOOP
  111.       CASE !(choice)= 'E' 
  112.         ***** Generate individual REPLACE statements
  113.         DO confield
  114.       CASE !(choice)= 'G' 
  115.         ***** Generate a command file to convert records 
  116.         ***** into new structure
  117.         DO congen
  118.       CASE !(choice)= 'R' .AND.(FILE( 'CONVERT.CMD' ).OR.;
  119.         FILE( 'CONVERT.PRG' ))
  120.         ***** Run the convert command file if it exists
  121.         DO convert
  122.         ERASE
  123.         SELECT PRIMARY
  124.         ?
  125.         ? 'You may now type "LIST" to view records.' 
  126.         ? 'To run the convert program again, type '+;
  127.         '"DO CON <RET>"' 
  128.         CANCEL
  129.       OTHERWISE
  130.         LOOP
  131.     ENDCASE 
  132.   ENDDO WHILE generate 
  133. ENDDO WHILE t 
  134. RETURN
  135.  
  136.