home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv6.zip / vac22os2 / ibmcobol / samples / smrtsort / sample1.c < prev    next >
Text File  |  1995-07-18  |  3KB  |  79 lines

  1. /**********************************************************/
  2. /*                                                        */ 
  3. /*  Licensed Material -- Property of IBM                  */    
  4. /*  5765-349                                              */
  5. /*  (c) Copyright IBM Corporation 1995                    */
  6. /*  All rights reserved                                   */
  7. /*                                                        */
  8. /**********************************************************/
  9.  
  10. /**********************************************************/
  11. /*                                                        */
  12. /* SMARTsort -- sample1.c                                 */
  13. /*                                                        */
  14. /* This program sorts three files of department members   */
  15. /* then merges the output of each sort to create a single */
  16. /* file of all departments and members.                   */
  17. /*                                                        */
  18. /**********************************************************/
  19.  
  20. #pragma linkage (SMARTsort,system)
  21. #include <string.h>
  22.                                           
  23. void main(void)
  24. {
  25.  
  26.  static char *sort_command="-s sort -k 2b,2";
  27.  static char *merge_command="-s merge -k 3b,3";
  28.  char SMARTcommand[100];
  29.  
  30.  /* Define file names that will be used */
  31.  static char *deptL92=".\\data\\dept.L92";
  32.  static char *deptJ69=".\\data\\dept.J69";
  33.  static char *dept403=".\\data\\dept.403";
  34.  static char *deptL92_sorted=".\\output\\dept.L92 ";
  35.  static char *deptJ69_sorted=".\\output\\dept.J69 ";
  36.  static char *dept403_sorted=".\\output\\dept.403 ";
  37.  static char *depts_merged=" -o .\\output\\dept.mrg ";
  38.  int rc;
  39.  
  40.  /*****************************************************************/
  41.  /* Build command string and call SMARTsort to sort file dept.L92 */
  42.  /*****************************************************************/
  43.  strcpy(SMARTcommand,sort_command);         
  44.  strcat(SMARTcommand," -o ");
  45.  strcat(SMARTcommand,deptL92_sorted);
  46.  strcat(SMARTcommand,deptL92);
  47.  rc=SMARTsort(SMARTcommand,NULL,NULL,NULL,NULL,NULL,NULL);
  48.  
  49.  /*****************************************************************/
  50.  /* Build command string and call SMARTsort to sort file dept.J69 */
  51.  /*****************************************************************/
  52.  strcpy(SMARTcommand,sort_command);
  53.  strcat(SMARTcommand," -o ");
  54.  strcat(SMARTcommand,deptJ69_sorted);
  55.  strcat(SMARTcommand,deptJ69);
  56.  rc=SMARTsort(SMARTcommand,NULL,NULL,NULL,NULL,NULL,NULL);
  57.  
  58.  /*****************************************************************/
  59.  /* Build command string and call SMARTsort to sort file dept.403 */
  60.  /*****************************************************************/
  61.  strcpy(SMARTcommand,sort_command);
  62.  strcat(SMARTcommand," -o ");
  63.  strcat(SMARTcommand,dept403_sorted);
  64.  strcat(SMARTcommand,dept403);
  65.  rc=SMARTsort(SMARTcommand,NULL,NULL,NULL,NULL,NULL,NULL);
  66.  
  67.  /****************************************************/
  68.  /* Build command string and call SMARTsort to merge */
  69.  /* all files sorted above.                          */
  70.  /****************************************************/
  71.  strcpy(SMARTcommand,merge_command);
  72.  strcat(SMARTcommand,depts_merged);
  73.  strcat(SMARTcommand,deptL92_sorted);
  74.  strcat(SMARTcommand,deptJ69_sorted);
  75.  strcat(SMARTcommand,dept403_sorted);
  76.  rc=SMARTsort(SMARTcommand,NULL,NULL,NULL,NULL,NULL,NULL);
  77.  
  78. }
  79.