next up previous
Next: MemInfoClass Up: simlib Previous: CallDebugger

CmdLineClass


     NAME
	  cmdlineclass - routines to read the commandline

     DESCRIPTION
	  Routines to read from	the argument line using	Simula system
	  internal routines. Use of these routines rather than going
	  to the primitive routines themself will gurantee portability
	  over a range of UNIX and Unix-like OS.

     EXAMPLE
	  Commandline in UNIX: prog -b -i=123 -t=Donald	abc def
	  This line contains three parameters:
	     -b	boolean	ParBool( b") returns true"
	     -i	integer	ParInt(	i",k) returns true and k
	     -t	text	ParText( t",txt) returns true and"
			Front(txt) =  Donald""
	  It also contains two arguments, abc and def.

     TERMINOLOGY
     DETAILED INTERFACE
	     class CmdLineClass;
	  Class	for reading information	from the  command  line	 using
	  the Simula

	  A parameter is a named parameter to the program.  Parameters
	  come	in  three types, Boolean, integer and text. Parameters
	  are either present or	not on the command line.

	  An argument is a string, not starting	with a '-' that	appear
	  on  the  command  line.  Arguments  are  numbered  and  many
	  programs can take a variable number of arguments.

	  In UNIX a parameter is syntactically distinguished  with  an
	  initial  '-'	and  values  are  separted with	a '=' from the
	  parameter name.

	  Using	this class means your program will show	a command-line
	  interface   similar	to   other   Simula  programs.	As  an
	  alternative,	the  class  UnixCommandLine  offers   a	  more
	  primitive  interface to the command line, making it possible
	  to write Simula programs mimicing all	the different versions
	  of command line interfaces used by Unix utilities.

	  Supers: -
	  Kind:	Instantiable
	  Init:	none
	  Sequencing: (ProgramName ParBool ParInt ParInt ParText
	  ArgCount ArgText)*

     OPERATIONS:
     ProgramName
	     procedure ProgramName(b);
	     name b;text b; ! Buffer for result;
	  Return name of the executing program.	  Result:  b:=<program
	  name>, b.setpos(string.length+1).

	  NOTE:	that b must be long enough to store the	result.

     ParBool
	     Boolean procedure ParBool(T);
	     text t; ! Name of parameter;
	  Return booolean value	of named parameter.

	  Result: true if t present, false if not.

     ParInt
	     Boolean procedure ParInt(T,V);
	     name V; integer V;	! Returned valeu - if any;
	     text t; ! Name of parameter;
	  Return Integer value of named	parameter.

	  Result: True and V=number if T=<number>  present,  False  if
	  not.

     ParText
	     Boolean procedure ParText(t,b);
	     name b; text b; ! Buffer for result (in B.sub(1,B.pos-
	     1));
	     text t; ! Name of the parameter asked for.;
	  Return text value of	named  parameter  in  T.   Result:  if
	  t=<string>	present	   return    True    and    b:=string,
	  b.setpos(string.length+1), return False if not.

	  NOTE:	that b must be long enough to store the	result.

     ArgCount
	     integer procedure ArgCount;
	  Return number	of arguments on	 the  command  line.   Result:
	  number of arguments.

     ArgText
	     Boolean procedure ArgText(ArgN,Buf);
	     name Buf;text Buf;	! Buffer to hold the result.;
	     integer ArgN;  ! Argument number to get. ;
	  Return text value of numbered	argument.  Result: if there is
	  a  ArgN:th argument, True is returned	and Buf:=the argument,
	  Buf.setpos(string.length+1), otherwise it return False.

	  NOTE:	that Buf must be long enough to	store the result.