home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Modula / Source / OPTIONS.DEF < prev    next >
Text File  |  1985-04-25  |  2KB  |  52 lines

  1. DEFINITION MODULE Options; (* AKG / LG 26.02.81/ PF 06.06.83 *)
  2.                  (********)
  3. (* 13.06.83 added: FileName,nofile,ChangeExtension   PF*)
  4.  
  5.  
  6.   EXPORT QUALIFIED FileNameAndOptions, GetOption, Termination,
  7.                    FileName, ChangeExtension;
  8.  
  9.   TYPE Termination = (normal, empty, can, nofile, esc);
  10.  
  11.   TYPE FileName = ARRAY [0..39] OF CHAR;      (*** computer dependent **)
  12.  
  13.  
  14.   PROCEDURE FileNameAndOptions
  15.         (VAR default : ARRAY OF CHAR;
  16.          VAR name    : ARRAY OF CHAR;
  17.          VAR term    : Termination; acceptOption: BOOLEAN);
  18.  
  19.     (*Read file name and options from terminal.
  20.       Reads until a <cr>, blank, <can>, <ctrl-y> or <esc> is typed.
  21.       To read the file name a default name can be proposed.
  22.       name returns the read file name.
  23.       term returns the status of the input termination:
  24.           normal : normally terminated
  25.           empty  : normally terminated, but name is empty
  26.           can    : <can> is typed, input line cancelled
  27.           nofile : <ctrl-y> is typed, no file specified, program should proceed.
  28.           esc    : <esc> is typed, no file specified, program should terminate.
  29.       If acceptOption is TRUE, then options preceded by '/' will be accepted.*)
  30.  
  31.   PROCEDURE GetOption(VAR optStr: ARRAY OF CHAR; VAR length: CARDINAL);
  32.  
  33.     (*To be called repeatedly after FileNameAndOptions, until length = 0.
  34.       The characters of the next option are returned in optstr
  35.       (terminated with a 0C character if length <= HIGH(optstr) ). *)
  36.  
  37.   PROCEDURE ChangeExtension
  38.     (VAR filename    : ARRAY OF CHAR;
  39.      VAR newExtension: ARRAY OF CHAR);
  40.     (* given a filename, change its extension to newExtension.
  41.        e.g. from a .MOD filename, build a .OBJ filename, in the format of
  42.        your operating system *)
  43.  
  44.    (* notes: type  FileName  should be used only for variable declarations,
  45.       In procedure declarations, ARRAY OF CHAR should be used. This makes
  46.       live easier.
  47.       type  Filename  should contain the filename in a printable form, but
  48.       this is not specified *)
  49.  
  50. END Options.
  51.  
  52.