home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 392.lha / RunForward_v3.0 / runf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-03  |  2.9 KB  |  77 lines

  1. /* RunForward utility Ver 3.0 by Federico Noferi 1990  */
  2. /* Attenzione: quando linkate Runf dovete linkarlo con */ 
  3. /* cback.o invece che con il classico c.o              */
  4.  
  5. #include"stdio.h"
  6. #include"string.h"
  7. #include"libraries/dosextens.h"
  8.  
  9. #define title1 "RunForward utility Ver. 3.0 by Federico Noferi  Running command: "
  10.  
  11. #define msg1 "\nSintax : Runf command [parameters]\n\n"
  12. #define msg2 "RunForward utility Ver. 3.0 by Federico Noferi 1990\n"
  13. #define msg3 "Please reports all bugs and any suggestion \nto A-BBS +39-55-225727 24h or MC-Link MC7598 NUA 022226500140\n"
  14. #define msg4 "or write to: Fderico Noferi\n"
  15. #define msg5 "             via Cavalcanti, 42\n"
  16. #define msg6 "             Firenze 50133, Italy\n"
  17. #define msg7 "             Tel. +39-55-572968"
  18.  
  19. #define msgg1 "\n\nRunForward utility: Error executing the command\n"
  20. #define msgg2 "\nNote: run command must be present in C: directory\n"
  21.  
  22.  
  23. long _stack = 4000;             /* Definizioni per usare il cback.o */
  24. char *_procname = "RunForward"; /* in modo che runf parta gia' in   */
  25. long _priority = 0;             /* multitasking.                    */
  26. long _BackGroundIO = 1;
  27. extern struct FileHandle *Open();
  28. main(argc,argv)
  29. int argc;
  30. char *argv[];
  31. {
  32.     char command[255],title[255];     
  33.     int i,success;
  34.     struct FileHandle *dfh;
  35.     strcat(title,"CON:0/10/640/96/"); /* Crea la stringa title che */
  36.     strcat(title,title1);           /* definisce la finestra da  */
  37.     strcat(title,argv[1]);            /* aprire.                   */
  38.     dfh=Open(title,MODE_NEWFILE);     /* Apre una finestra sul dos */
  39.     if (argc==1)                          
  40.     {                                     /* Se non ci sono parametri */
  41.         Write(dfh,msg1,strlen(msg1)); /* visualizza il messaggio  */
  42.         Write(dfh,msg2,strlen(msg2)); /* definito dai #define.    */
  43.         Write(dfh,msg3,strlen(msg3));
  44.         Write(dfh,msg4,strlen(msg4));
  45.         Write(dfh,msg5,strlen(msg5));
  46.         Write(dfh,msg6,strlen(msg6));
  47.         Write(dfh,msg7,strlen(msg7));
  48.         Delay(200);  /* Aspetta 4 secondi  */
  49.         Close(dfh);  /* chiude la finestra */
  50.         exit(10);    /* e poi esce.        */ 
  51.     }
  52.     i=1;
  53.     while (i<argc)
  54.     {
  55.         strcat(command,argv[i]);   /* Compone la stringa con i */
  56.         strcat(command," ");       /* comandi da passare alla  */
  57.         i++;                       /* funzione Execute.                 */
  58.     }
  59.     strcat(command,"\nendcli\n") ;     /* Aggiunge un endcli per   */
  60.                            /* far chiudere la finestra */
  61.                        /* a fine esecuzione.       */
  62.     success=Execute(command,dfh,dfh);  /* Esegue i comandi presenti*/
  63.                        /* nella stringa command.   */    
  64.     if (success==NULL)                 
  65.     {
  66.         Write(dfh,msgg1,strlen(msgg1)); /* Se Execute fallisce */
  67.         Write(dfh,msgg2,strlen(msgg2)); /* da' un messaggio di */
  68.         Delay(150);                     /* errore, chiude la   */
  69.         Close(dfh);                     /* la finestra e esce. */
  70.         exit(20);
  71.     }
  72.     Delay(200);  /* Ritardo di 4 secondi prima di chiudere la finestra */             
  73.     Close(dfh);  /* Chiude la finestra */
  74. }
  75.  
  76.  
  77.