home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 2: PC / frozenfish_august_1995.bin / bbs / d01xx / d0113.lha / NoIconPos / noIconPos.mod < prev    next >
Text File  |  1987-11-21  |  3KB  |  101 lines

  1. MODULE noIconPos;
  2. (* 4-Nov-87/ms
  3.  * noIconPos  clears  position  information in any icon. This  is especially
  4.  * useful  for  disk and drawer icons.  If you snapshot the  drawer's window
  5.  * the position of the icon itself is written too. Useless to say, that this
  6.  * program  runs  from  Workbench  or CLI,  also there are NO OpenLibrary or
  7.  * CloseLibrary calls needed in this program. Thanx to M2Amiga!
  8.  *)
  9. (* This program is Copyright 1987 by Markus Schaub/AMSoft. The author hereby
  10.  * gives permission to distribute it's source and executable, in whole only,
  11.  * via any  media.  This program  can not  be sold  for profit  or used in a
  12.  * commercial product. All other rights are reserved.
  13.  *
  14.  * Markus Schaub
  15.  * c/o Interface Technologies Corp.
  16.  * 3336 Richmond #323            (713) 523 8422
  17.  *)
  18. FROM SYSTEM IMPORT
  19.  ADR;
  20. FROM Arguments IMPORT
  21.  GetArg,GetLock,NumArgs;
  22. FROM Arts IMPORT
  23.  Assert,TermProcedure;
  24. FROM ASCII IMPORT
  25.  nul;
  26. FROM Dos IMPORT
  27.  FileInfoBlockPtr,FileLockPtr,CurrentDir,Examine,ParentDir,UnLock;
  28. FROM Exec IMPORT
  29.  MemReqs,MemReqSet,AllocMem,CopyMem,FreeMem;
  30. FROM Icon IMPORT
  31.  FreeDiskObject,GetDiskObject,PutDiskObject;
  32. FROM Terminal IMPORT
  33.  WriteLn,WriteString;
  34. FROM Workbench IMPORT
  35.  noIconPosition,DiskObjectPtr;
  36.  
  37. VAR
  38.  arg,len: INTEGER;
  39.  diskObject: DiskObjectPtr;
  40.  fib: FileInfoBlockPtr;
  41.  lock: FileLockPtr;
  42.  name: ARRAY [0..127] OF CHAR;
  43.  
  44. PROCEDURE Cleanup;
  45. BEGIN
  46.  IF fib#NIL THEN FreeMem(fib,SIZE(fib^)) END
  47. END Cleanup;
  48.  
  49. BEGIN
  50.  fib:=NIL;
  51.  TermProcedure(Cleanup);
  52.  WriteString("noIconPos, 1.0, 4-Nov-87, ⌐ AMSoft"); WriteLn;
  53.  arg:=1;
  54.  GetArg(arg,name,len);
  55.  IF (NumArgs()=0) OR (name[0]='?') THEN
  56.   GetArg(0,name,len);
  57.   WriteString("Usage: "); WriteString(name); WriteString(" {files}"); WriteLn
  58.  ELSE
  59.   (* allocate this block! it has to be longword aligned. Stupid BCPL! *)
  60.   fib:=AllocMem(SIZE(fib^),MemReqSet{memClear});
  61.   Assert(fib#NIL,ADR("No memory for FileInfoBlock"));
  62.   WHILE arg<=NumArgs() DO
  63.    GetArg(arg,name,len);
  64.    lock:=NIL;
  65.    IF name[0]=nul THEN
  66.     lock:=ParentDir(GetLock(arg));
  67.     IF lock=NIL THEN
  68.      name:="Disk"
  69.     ELSIF Examine(GetLock(arg),fib)#0 THEN
  70.      CopyMem(ADR(fib^.fileName),ADR(name),SIZE(name));
  71.      lock:=CurrentDir(lock);
  72.     END
  73.    END;
  74.    INC(arg);
  75.    IF name[0]#nul THEN
  76.     diskObject:=GetDiskObject(ADR(name));
  77.     WriteString(name);
  78.     IF diskObject#NIL THEN
  79.      WITH diskObject^ DO
  80.       currentX:=noIconPosition; currentY:=noIconPosition;
  81.      END;
  82.      IF PutDiskObject(ADR(name),diskObject)#0 THEN
  83.       WriteString(": Position cleared")
  84.      ELSE
  85.       WriteString(": Error while writing Icon back")
  86.      END;
  87.      FreeDiskObject(diskObject)
  88.     ELSE
  89.      WriteString(": Icon not found")
  90.     END
  91.    ELSE
  92.     WriteString(": No name found")
  93.    END;
  94.    WriteLn;
  95.    IF lock#NIL THEN
  96.     lock:=CurrentDir(lock); UnLock(lock)
  97.    END;
  98.   END
  99.  END
  100. END noIconPos.
  101.