home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / dev / obero / oberon-a / examples / libraries / workbench / prargs.mod < prev    next >
Encoding:
Text File  |  1994-08-08  |  2.4 KB  |  86 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.2 $
  8.       $Author: fjc $
  9.         $Date: 1994/08/08 16:59:51 $
  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. MODULE PrArgs;
  20.  
  21. (*
  22. ** $C= CaseChk       $I= IndexChk  $L= LongAdr   $N= NilChk
  23. ** $P- PortableCode  $R= RangeChk  $S= StackChk  $T= TypeChk
  24. ** $V= OvflChk       $Z= ZeroVars
  25. *)
  26.  
  27. IMPORT SYS := SYSTEM, Dos, Args, IO := StdIO;
  28.  
  29. CONST
  30.   VersionTag = "\0$VER: PrArgs 1.0 (18.6.94)\r\n";
  31.  
  32. VAR
  33.   ktr : LONGINT;
  34.   olddir : Dos.FileLockPtr;
  35.  
  36. BEGIN (* PrArgs *)
  37.   IF Args.IsCLI THEN
  38.     IO.WriteF1 ("Run from the CLI, %ld args.\n", Args.argc);
  39.     FOR ktr := 0 TO Args.argc - 1 DO
  40.       (* Print an arg, and its number *)
  41.       IO.WriteF2 ("\tArg %2.2ld: '%s'.\n", ktr, Args.argv [ktr])
  42.     END
  43.   ELSE
  44.     IO.WriteF1 ("Run from the Workbench, %ld args.\n", Args.NumArgs);
  45.     FOR ktr := 0 TO Args.NumArgs - 1 DO
  46.       IF Args.ArgList [ktr].lock # NIL THEN
  47.         (* locks supported, change to the proper directory *)
  48.         olddir := Dos.base.CurrentDir (Args.ArgList [ktr].lock);
  49.  
  50.         (* process the file.
  51.         ** If you have done the CurrentDir() above, then you can
  52.         ** access the file by its name.  Otherwise, you have to
  53.         ** examine the lock to get a complete path to the file.
  54.         *)
  55.         IO.WriteF2
  56.           ( "\tArg %2.2ld (w/ lock): '%s'.\n",
  57.             ktr, Args.ArgList [ktr].name );
  58.  
  59.         (* change back to the original directory when done.
  60.         ** be sure to change back before you exit.
  61.         *)
  62.         olddir := Dos.base.CurrentDir (olddir)
  63.       ELSE
  64.         (* something that does not support locks *)
  65.         IO.WriteF2
  66.           ( "\tArg %2.2ld (no lock): '%s'.\n",
  67.             ktr, Args.ArgList [ktr].name )
  68.       END;
  69.     END;
  70.     (* wait before closing down *)
  71.     Dos.base.Delay (500)
  72.   END;
  73. END PrArgs.
  74.  
  75. (*************************************************************************
  76.  
  77.   $Log: PrArgs.mod $
  78.   Revision 1.2  1994/08/08  16:59:51  fjc
  79.   Release 1.4
  80.  
  81.   Revision 1.1  1994/06/18  22:59:44  fjc
  82.   Initial revision
  83.  
  84. *************************************************************************)
  85.  
  86.