exec.red 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. %
  2. % EXEC.RED - Simple TOPS20 Interfaces, "EXEC Fork", etc
  3. %
  4. % Author: Martin L. Griss and Eric Benson
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 8 March 1981
  9. % Copyright (c) 1981 University of Utah
  10. %
  11. % <PSL.UTIL>EXEC.RED.5, 24-May-82 13:01:50, Edit by BENSON
  12. % Changed <EDITORS> and <SUBSYS> to SYS: in filenames
  13. %/ Changed FILNAM->FileName, due to GLOBAL conflict
  14. %/ Changed JSYS calls, so LIST(..) rather than '(..) used
  15. %/ Changed for V3:JSYS
  16. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  17. % Simple JSYS interfaces
  18. imports '(JSYS);
  19. GLOBAL '(ForkNAMES!* EXECFork EMacsFork MMFork);
  20. Lisp procedure GetOLDJfn FileName; %. test If file OLD and return Jfn
  21. Begin scalar Jfn;
  22. If NULL StringP FileName then return NIL;
  23. Jfn := JSYS1(Bits(2,3,17),FileName,0,0,jsGTJfn);
  24. % OLD!MSG!SHORT
  25. If Jfn<0 then return NIL;
  26. return Jfn
  27. END;
  28. Lisp procedure GetNEWJfn FileName; %. test If file NEW and return Jfn
  29. Begin scalar Jfn;
  30. If NULL StringP FileName then return NIL;
  31. Jfn := JSYS1(Bits(0,1,3,17),FileName,0,0,jsGTJfn);
  32. % GEN!NEW!MSG!SHORT
  33. If Jfn<0 then return NIL;
  34. return Jfn
  35. END;
  36. Lisp procedure RELJfn Jfn; %. return Jfn to system
  37. JSYS0(Jfn,0,0,0,jsRLJfn);
  38. Lisp procedure OPENOLDJfn Jfn; %. OPEN to READ
  39. JSYS0(Jfn,Bits( (7 . 5),19),0,0,jsOPENF);
  40. Lisp procedure OPENNEWJfn Jfn; %. Open to WRITE
  41. JSYS0(Jfn,Bits( (7 . 5),20),0,0,jsOPENF);
  42. Lisp procedure GetFork Jfn; %. Create Fork, READ File on Jfn
  43. Begin scalar FH;
  44. FH := JSYS1(Bits(1),0,0,0,jsCFork);
  45. JSYS0(Xword(FH ,Jfn),0,0,0,jsGet);
  46. return FH
  47. END;
  48. Lisp procedure STARTFork FH; %. Start (Restart) a Fork
  49. JSYS0(FH, 0,0,0,jsSFRKV);
  50. Lisp procedure WAITFork FH; %. Wait for completion
  51. JSYS0(FH,0,0,0,jsWFork);
  52. Lisp procedure RUNFork FH; %. Normal use, to run a Fork
  53. <<STARTFork FH; WAITFork FH>>;
  54. Lisp procedure KILLFork FH; %. Kill a Fork
  55. JSYS0(FH,0,0,0,jsKFork);
  56. Lisp procedure SETPRIMARYJfnS(FH,INJfn,OUTJfn);
  57. JSYS0(FH,Xword(INJfn , OUTJfn),0,0,JSSPJfn); %. Change PRIMARY Jfns (BAD?)
  58. Lisp procedure OPENFork FileName; %. Get a File into a Fork
  59. Begin scalar FH,Jfn;
  60. If NULL FileP FileName then StdError CONCAT("Cant find File ",FileName);
  61. Jfn := GetOLDJfn FileName;
  62. FH := GetFork Jfn;
  63. return FH
  64. END;
  65. Lisp procedure RUN FileName; %. Run A File
  66. Begin scalar FH; FH := OPENFork FileName; RUNFork FH; KILLFork FH END;
  67. Lisp Procedure ForkP FH; %. test if Valid Fork Handle
  68. FixP FH and not Zerop FH; %/Kludge
  69. Lisp procedure EXEC;
  70. <<If Not ForkP EXECFork then EXECFork := OPENFork "SYSTEM:EXEC.EXE";
  71. RUNFork EXECFork>>;
  72. Lisp procedure EMACS;
  73. <<If Not ForkP EMacsFork then EMACSFork := OPENFork "SYS:EMACS.EXE";
  74. RUNFork EMACSFork>>;
  75. Lisp procedure MM;
  76. <<If Not ForkP MMFork then MMFork := OPENFork "SYS:MM.EXE";
  77. RUNFork MMFork>>;
  78. Lisp procedure GetUNAME; %. USER name
  79. Begin Scalar S;
  80. S:=Mkstring 80;
  81. JSYS0(s,JSYS1(0,0,0,0,JSGJINF),0,0,JSDIRST);
  82. Return RecopyStringToNULL S
  83. End;
  84. Lisp procedure GetCDIR; %. Connected DIRECTORY
  85. Begin scalar s;
  86. S:=Mkstring 80;
  87. JSYS0(S,JSYS2(0,0,0,0,jsGJINF),0,0,jsDIRST);
  88. return RecopyStringToNULL S
  89. end;
  90. Lisp procedure PSOUT S; %. Print String
  91. JSYS0(S,0,0,0,jsPSOUT);
  92. Lisp procedure GTJfn L; %. Get a Jfn
  93. JSYS1(L,0,0,0,jsGTJFN);
  94. Lisp procedure NAMEFROMJfn J; %. name of File on a Jfn
  95. Begin scalar S;
  96. s:=Mkstring 100;
  97. JSYS0(S,J,0,0,JSJfnS);
  98. return RecopyStringToNULL S;
  99. end;
  100. Fexpr Procedure InFile(U); %. INPUT FILE, (prompt for name too?)
  101. If StringP U then DskIn EVAL CAR U
  102. else
  103. Begin scalar Jfn,Fname;
  104. PSOUT "Input file:";
  105. Jfn:=Jsys1(BITS(2,3,4,16,17),Xword(8#100,8#101),0,0,jsGTJFN);
  106. Fname:= NAMEFROMJFN JFN;
  107. RELJFN JFN;
  108. PRINTF("reading file %r %n", FNAME);
  109. DSKIN Fname;
  110. end;
  111. %-- Command string processor and take
  112. Lisp procedure PutRescan(S); %. Enter String
  113. <<JSYS0(S,0,0,0,jsRSCAN);
  114. JSYS0(0,0,0,0,jsRSCAN)>>;
  115. On SYSLISP;
  116. syslsp procedure GetRescan(); %. Return as String
  117. Begin scalar N,S;
  118. XJSYS1(0,0,0,0,jsRSCAN); % Announce to Get
  119. N:=XJSYS1(1,0,0,0,jsRSCAN); % How Many
  120. IF N=0 then return 'Nil;
  121. S:=GtStr N-1; % To Drop Trailing EOL
  122. For I:=0:N-2 do
  123. StrByt(S,I):=XJsys1(0,0,0,0,JsPBIN);
  124. Return MkSTR S; % Will include Program name
  125. end;
  126. OFF SYSLISP;
  127. Global '(CRLF BL);
  128. CRLF :=STRING(8#15,8#12); %. CR-LF
  129. BL :=STRING(8#40); %. Blank
  130. Lisp procedure CONCATS (L); %. Combine list of strings
  131. If PAIRP L then CONCAT(CAR L,CONCATS CDR L)
  132. else CRLF;
  133. Lisp Fexpr Procedure CMDS (!%L); %. user COMMAND submit
  134. DOCMDS EVLIS !%L;
  135. Lisp procedure DOCMDS (L); %. Submit via PutRescan
  136. <<PutRescan CONCATS L; % Add CR, plant in RSCAN
  137. EXEC()>>; % Run 'em
  138. %. -------- Sample Commands
  139. Lisp procedure VDIR (L);
  140. DOCMDS LIST("VDIR ",L,CRLF,"POP");
  141. Lisp procedure HelpDir();
  142. DOCMDS LIST("DIR PH:*.HLP",CRLF,"POP");
  143. Lisp procedure Take (FileName);
  144. If FileP FileName then DOCMDS LIST("Take ",FileName,CRLF,"POP");
  145. Lisp procedure SYS (L);
  146. DOCMDS LIST("SYS ", L, CRLF, "POP");
  147. Lisp procedure TALK (L);
  148. DOCMDS LIST("TALK ",L,CRLF);
  149. Lisp procedure TYPE (L);
  150. DOCMDS LIST("TYPE ",L,CRLF,"POP");
  151. END;