Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /*
  5. Typical use:
  6.  
  7. PScriptGen 256 SPK SPKC FP WB _CH
  8.  
  9. This will generate lines like:
  10. SPK001,SPKC001,FP001,WB001,_CH001
  11. SPK002,SPKC002,FP002,WB002,_CH002
  12. SPK003,SPKC003,FP003,WB003,_CH003
  13. */
  14.  
  15.  
  16. FILE *file;
  17. char *filename = "c:\\PlexonData\\plexutilbatch.txt";
  18.  
  19. int main(int argc, char *argv[])
  20. {
  21.  
  22.     if (argc < 4 || argc > 7)
  23.     {
  24.         printf("Not enough arguments, or too many arguments.\n");
  25.         return 0;
  26.     }
  27.  
  28.     file = fopen(filename, "w");
  29.     if (file == NULL)
  30.     {
  31.         printf("File couldn't open\n");
  32.     }
  33.  
  34.     int channels = atoi(argv[1]);
  35.     int fields = argc - 2;
  36.     int x, y;
  37.  
  38.     //Ok, here we go.
  39.  
  40.     for (x = 0; x < channels; x++)
  41.     {
  42.         for (y = 0; y < fields ; y++)
  43.         {
  44.             fprintf(file, "%s%03d",argv[y + 2], x + 1);
  45.  
  46.             if (y < fields - 1)
  47.             {
  48.                 fprintf(file, ", ");
  49.             }
  50.         }
  51.         fprintf(file, "\n");
  52.     }
  53.  
  54.     return 0;
  55. }
  56.