home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / Oberon / examples.lha / Examples / Libraries / Workbench / PrArgs.mod < prev    next >
Encoding:
Text File  |  1995-07-02  |  2.4 KB  |  89 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: PrArgs.mod $
  4.   Description: A port of prargs.c from the RKM:Libraries
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 1.4 $
  8.       $Author: fjc $
  9.         $Date: 1995/01/25 23:56:20 $
  10.  
  11.   Copyright © 1994, Frank Copeland.
  12.   This example program is part of Oberon-A.
  13.   See Oberon-A.doc for conditions of use and distribution.
  14.  
  15.   Log entries are at the end of the file.
  16.  
  17. *************************************************************************)
  18.  
  19. <* STANDARD- *>
  20.  
  21. MODULE PrArgs;
  22.  
  23. IMPORT Dos, Args, IO := StdIO;
  24.  
  25. CONST
  26.   VersionTag = "$VER: PrArgs 1.2 (19.9.94)\r\n";
  27.  
  28. VAR
  29.   ktr : LONGINT;
  30.   olddir : Dos.FileLockPtr;
  31.  
  32. BEGIN (* PrArgs *)
  33.   IF Args.IsCLI THEN
  34.     IO.WriteF1 ("Run from the CLI, %ld args.\n", Args.argc);
  35.     FOR ktr := 0 TO Args.argc - 1 DO
  36.       (* Print an arg, and its number *)
  37.       IO.WriteF2 ("\tArg %2.2ld: '%s'.\n", ktr, Args.argv [ktr])
  38.     END
  39.   ELSE
  40.     IO.WriteF1 ("Run from the Workbench, %ld args.\n", Args.NumArgs);
  41.     FOR ktr := 0 TO Args.NumArgs - 1 DO
  42.       IF Args.ArgList [ktr].lock # NIL THEN
  43.         (* locks supported, change to the proper directory *)
  44.         olddir := Dos.CurrentDir (Args.ArgList [ktr].lock);
  45.  
  46.         (* process the file.
  47.         ** If you have done the CurrentDir() above, then you can
  48.         ** access the file by its name.  Otherwise, you have to
  49.         ** examine the lock to get a complete path to the file.
  50.         *)
  51.         IO.WriteF2
  52.           ( "\tArg %2.2ld (w/ lock): '%s'.\n",
  53.             ktr, Args.ArgList [ktr].name );
  54.  
  55.         (* change back to the original directory when done.
  56.         ** be sure to change back before you exit.
  57.         *)
  58.         olddir := Dos.CurrentDir (olddir)
  59.       ELSE
  60.         (* something that does not support locks *)
  61.         IO.WriteF2
  62.           ( "\tArg %2.2ld (no lock): '%s'.\n",
  63.             ktr, Args.ArgList [ktr].name )
  64.       END;
  65.     END;
  66.     (* wait before closing down *)
  67.     Dos.Delay (500)
  68.   END;
  69. END PrArgs.
  70.  
  71. (*************************************************************************
  72.  
  73.   $Log: PrArgs.mod $
  74.   Revision 1.4  1995/01/25  23:56:20  fjc
  75.   - Release 1.5
  76.  
  77.   Revision 1.3  1994/09/25  18:37:50  fjc
  78.   - Uses new syntax for external code declarations
  79.  
  80.   Revision 1.2  1994/08/08  16:59:51  fjc
  81.   Release 1.4
  82.  
  83.   Revision 1.1  1994/06/18  22:59:44  fjc
  84.   Initial revision
  85.  
  86. *************************************************************************)
  87.  
  88.  
  89.