perm filename STD.DOC[LIB,AIL] blob sn#408143 filedate 1979-01-09 generic text, type T, neo UTF8
require "[][]" delimiters;
define ! =[comment];

! Library routines from LIBRAR.REL or HLIBRA.REL
    LIBRAR.REL made by compiling:
          READCA.SAI
          NEWLIN.SAI
          INTEOF.SAI
          REALEO.SAI
          STREOF.SAI
          STRIN.SAI
          TINIT.SAI
          IOPKG.SAI
          DEFAU.SAI
          SPLIT.SAI
          FILEEX.SAI
          DATES.SAI
          FILSCN.SAI
          EOFTRU.FAI    (HEOFTR.FAI for HLIBRA.REL)
          LOWERC.SAI
          UPPERC.SAI
          TRIM.SAI
          RELALL.SAI
          CEIL.SAI
          GETPPN.SAI
    then using FUDGE2 to make the library.
    The object files in library should be in same order as
    corresponding source files above. The command files
    LIBRAR.MIC and HLIBRA.MIC will construct the libraries automatically.
    Use the commands

          DO LIBRAR.MIC LIBRAR
          DO HLIBRA.MIC HLIBRA

    respectively;



! Switch setting things;

define DefaultSwitch(SwitchName,Value) =
   [ ifcr declaration(SwitchName) = 0 thenc
        define SwitchName = [Value];
     elsec
        ifcr not (declaration(SwitchName) land Check!Type(Define)) thenc
           require '15&'12&"Illegal argument to DefaultSwitch - "&
                   cvps(SwitchName) message;
        endc
     endc
   ];

DefaultSwitch(Library!Entry,0); ! Normally not a library entry;
DefaultSwitch(!WntAlg,1); ! Normally want ALGOL-W like I/O;
DefaultSwitch(!WntDates,0); ! Normally do not want the DATES package;
DefaultSwitch(!WntCalli,0); ! Normally do not want the CALLI package;
DefaultSwitch(!WntPath,0); ! Normally do not want the PATH's package;
define ReadCompilerSwitch (SwitchChar, SwitchVal) =
  [ require "<><>" delimiters;
    assignc SwitchChar = cvps(SwitchChar) land '137;
    ifcr (SwitchChar leq "@") or (SwitchChar geq "Z") thenc
       require "Invalid argument To ReadCompilerSwitch-"
                 &SwitchChar message;
       # #
    endc

    redefine !!Mac!Aux = cvms(compiler!banner);
    ifcr cvms(!!Mac!Aux)[inf for 1] neq """" thenc
       require CrLf&"String constant following first BEGIN is too long."
               &CrLf&"Potential problems in Std.Hdr" &CrLf Message;
    endc
    redefine SwitchVal = <>;
    redefine !!Mac!Cnt = 1;
    redefine !!Switch!Str = ScanC(cvms(!!Mac!Aux),SwitchChar,Null,
                                      "INS");
    ifcr length(cvms(!!Mac!Aux)) = length(cvms(!!Switch!Str)) thenc
         require CrLf&"Invalid argument to ReadCompilerSwitch "&
            SwitchChar&CrLf message;
         # #
    endc
    whilec < !!Mac!Cnt neq 0 > doc
      <
         redefine !!Mac!Aux = cvms(!!Mac!Aux)[
                       length(cvms(!!Switch!Str))+2 to inf];
         redefine !!Next!Str = ScanC(cvms(!!Mac!Aux),SwitchChar,null,
                                     "INS");
         ifcr length(cvms(!!Next!Str)) neq length(cvms(!!Mac!Aux)) thenc
            redefine !!Switch!Str = cvms(!!Next!Str);
         elsec
            redefine !!Mac!Cnt = length(cvms(!!Switch!Str));
            whilec <!!Mac!Cnt neq 0 > doc
               < redefine SwitchVal = cvms(!!Switch!Str)
                                         [!!Mac!Cnt for 1] &
                                      cvms(SwitchVal);
                 ifcr cvms(!!Switch!Str)[!!Mac!Cnt-1 for 1] leq '52 thenc
                     redefine !!Mac!Cnt = 0;
                     redefine !!Next!Str = <>;
                     redefine !!Mac!Aux = <>;
                     redefine !!Switch!Str = <>;
                 elsec
                     redefine !!Mac!Cnt = !!Mac!Cnt - 1;
                 endc
               > endc
         endc
      > endc

     require unstack!delimiters;
  ];
! macros for special characters;

define CrLf = [('15&'12)];
define CR = [(null&'15)];
define LF = [(null&'12)];
define TAB = [(null & '11)];
define FF = [(null & '14)];
define Bell = [(null & '7)];
define BackSpace = [(null & '10)];


! halfword constructors and selectors;

define xwd(L,R) = [  ! for making up halfwords into full word;
      (((L) lsh 18) lor ((R) land '777777))];
define lh(X) = [ ((X) lsh -18) ];
define rh(X) = [ ((X) land '777777)];

! external names used by loader are restricted to 6 characters. Thus
  if we wish to have a name longer than 6 characters we may have to
  define a shorter (6 or less character) name. We use
  the following LoaderAlias macro to define the short name;

define LoaderAlias(LongName, ShortName) =
  [ assignc ShortName = ScanC(cvps(ShortName),""," ","I");
    define LongName = [ShortName]
   ];

! at point of definition of LoaderAlias name the following
  macro may be used as a comment. It will cause an error
  message if the names given here are inconsistent with the original
  LoaderAlias;

define LoaderAliasIs(LongName,ShortName) =
  [ assignc ShortName = ScanC(cvps(ShortName),""," ","I");
    ifcr (declaration(LongName) land check!type(define)) neq
         check!type(define) thenc
       require CrLf&"Missing LoaderAlias definition for "&
               cvps(LongName) message;
    elsec ifcr not Equ(cvms(LongName),cvps(ShortName)) thenc
             require CrLf&"LoaderAlias inconsistency for "&
                     cvps(LongName) message;
          endc
    endc
  ];


! Input Output things;

external simple integer procedure OpenIn(string FName;
    reference boolean Eof; integer Mode(0));

external simple integer procedure OpenOut(string FName;
    integer Mode(0));

external simple boolean procedure File!Exists(string FName);
external simple boolean procedure FileScan(string FName;
    reference string Dev,Name,Ext,PPN);

external procedure NewLine(integer Chan);
external integer procedure IntEof(integer Chan);
external real procedure RealEof(integer Chan);
external string procedure StrEof(integer Chan);
external integer !t!t!y;
external integer !t!e!o!f;
external simple procedure !t!i!n!i!t;

! close all files on exit from main block;
external simple procedure r!e!l!a!l!l;

! string things;
external simple string procedure Trim(string Arg);
external simple string procedure UpperCase(string Arg);
external simple string procedure LowerCase(string Arg);

! a call to the GETPPN UUO to return the PPN of the running job;
external string procedure GetPPN;
! convert real to integer;
external simple integer procedure Ceil( real X);
external simple integer procedure Floor (real X);



! John Shopiro's SWITCH.INI reader and switch processor;
external simple boolean procedure Default!Switches
    (reference string Switch!Text; string Prog!Name,
     Option!Name (null));

external procedure Split!Switches
    (string Switch!text; reference string array Switch!Names,
     Switch!Values);

ifcr not library!entry then
   readcompilerswitch(h,!!MM!!!!); ! reentrant compilation?;
   ifcr !!MM!!!! thenc
      require "hlibrar.rel[lib,sys]" library;
   elsec
      require "library.rel[lib,sys]" library;
   endc
   cleanup r!e!l!a!l!l;
endc


ifcr !WntAlg thenc
   require "all:algwio.hdr[170,161]" source!file;
endc

ifcr !WntDates thenc
   require "cs:dates.hdr" source!file;
endc

ifcr !WntCalli thenc
   require "cs:calli.hdr" source!file;
endc

ifcr !WntPath thenc
   require "cs:path.hdr" source!file;
endc