home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / utilities / u620.dms / in.adf / Tips&Tricks / DOS-Intuition / ShellDepth.c < prev   
Encoding:
C/C++ Source or Header  |  1992-04-28  |  1.8 KB  |  74 lines

  1. //    ShellDepth         $VER: v1.0 1991-07-28       E. Lundevall
  2. //
  3. //    Move the current shell window to the front or to the back
  4.  
  5. #include <exec/types.h>
  6. #include <exec/memory.h>
  7. #include <dos/dosextens.h>
  8. #include <dos/rdargs.h>
  9. #include <clib/exec_protos.h>
  10. #include <clib/dos_protos.h>
  11.  
  12. #define TEMPLATE (UBYTE *)"FRONT/S,BACK/S,VERBOSE/S"
  13.  
  14. struct IntuitionBase *IntuitionBase;
  15.  
  16. UBYTE vertxt[] = "\0$VER: v1.0_1991-07-28";
  17.  
  18.  
  19. void NeedKS20()
  20. {
  21.  UBYTE only20txt[] = "Sorry, I need Kickstart 2.0x. ";
  22.  
  23.  only20txt[strlen(only20txt)-1] = 10; // LF at EOLN.
  24.  if(DOSBase->lib_Version < 36) {
  25.     Write(Output(),only20txt,strlen(only20txt));
  26.     exit(20);
  27.  }
  28. }
  29.  
  30.  
  31. int main(void)
  32. {
  33.  struct InfoData  *id;
  34.  struct RDArgs    *rda;
  35.  LONG             args[3] = { 0,0,0 };
  36.  
  37.  NeedKS20();    // Abort if not Kickstart 2.0x
  38.  
  39.  if(!GetConsoleTask())
  40.     exit(10);       // Exit if no Shell.
  41.  
  42.  if(!(rda = ReadArgs(TEMPLATE,args,NULL))) {
  43.     PrintFault(IoErr(),NULL);
  44.     exit(10);
  45.  }
  46.  if(!(id = AllocVec(sizeof(struct InfoData),MEMF_CLEAR|MEMF_PUBLIC))) {
  47.     VPrintf((UBYTE *)"Not enough memory!\n",NULL);
  48.         FreeArgs(rda);
  49.     exit(10);
  50.  }
  51.  if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary((UBYTE *)"intuition.library",36))) {
  52.     VPrintf((UBYTE *)"Couldn't open intuition.library!\n",NULL);
  53.         FreeArgs(rda);
  54.     exit(10);
  55.  }
  56.  
  57.  if(DoPkt(GetConsoleTask(),ACTION_DISK_INFO,MKBADDR(id),0,0,0,0)) {
  58.     if(args[2]) {
  59.         UBYTE* text = args[0] ? (UBYTE*)"front" :
  60.                       args[1] ? (UBYTE*)"back"  : (UBYTE*)"same";
  61.         VPrintf((UBYTE*)"Shell -> %s\n",(LONG*)&text);
  62.     }
  63.     if(args[0]) // Got front switch ?
  64.         WindowToFront(id->id_VolumeNode);
  65.     else if(args[1])  // Got back switch ?
  66.         WindowToBack(id->id_VolumeNode);
  67.  }
  68.  else PrintFault(IoErr(),NULL);
  69.  CloseLibrary((struct Library*)IntuitionBase);
  70.  FreeArgs(rda);
  71.  FreeVec(id);
  72.  exit(0);
  73. }
  74.