main2.red 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. % MAIN2.RED - Test Byte and String I/O, some PRINT ing
  2. % Need: SUB2.RED simple print routines
  3. IN "XXX-HEADER.RED"$
  4. on SysLisp;
  5. % some strings to work with
  6. WString TestString = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUnVvWwXxYyZz";
  7. Wstring Buffer[100];
  8. syslsp Procedure FirstCall;
  9. begin scalar X, Y;
  10. init();
  11. % test STRINF
  12. Putc Char S;
  13. PutC Char Lower t;
  14. PutC Char Lower r;
  15. Putc Char I;
  16. Putc Char Lower n ;
  17. Putc Char Lower f;
  18. Putc Char Eol;
  19. X:=TestString;
  20. Y:=StrInf(X);
  21. PutInt X; PutC Char '! ; PutInt Y;PutC Char EOL;
  22. % test STrlen
  23. Putc Char S;
  24. PutC Char Lower t;
  25. PutC Char Lower r;
  26. Putc Char Lower l;
  27. Putc Char Lower e;
  28. Putc Char Lower n;
  29. Putc Char Eol;
  30. X:=StrLen(testString);
  31. PutInt X;PutC Char '! ;PutInt 51;PutC Char EOL;
  32. % test Byte access.
  33. X:=TestString+AddressingUnitsPerItem;
  34. Putc Char B;
  35. PutC Char Lower y;
  36. PutC Char Lower t;
  37. Putc Char Lower e;
  38. Putc Char Eol;
  39. For i:=0:10 do
  40. <<Y:=Byte(X,i);
  41. PutInt i; PutC Char '! ;
  42. PutInt Y; PutC Char '! ;
  43. PutC Y; PutC Char EOL>>;
  44. % Now a string:
  45. Putc Char S;
  46. PutC Char Lower t;
  47. PutC Char Lower r;
  48. Putc Char Lower i;
  49. Putc Char Lower n;
  50. Putc Char Lower g;
  51. Putc Char Eol;
  52. Prin2String TestString;
  53. Terpri();
  54. Prin1String "----- Now input characters until #";
  55. Terpri();
  56. while (X := GetC X) neq char !# do PutC X;
  57. Print '"----- First Print Called";
  58. Print '1;
  59. Print 'ANATOM;
  60. Print '( 1 . 2 );
  61. Print '(AA (B1 . B2) . B3);
  62. Print '(AA (B1 . NIL) . NIL);
  63. Prin2T
  64. "Expect UNDEFINED FUNCTION MESSAGE for a function of 3 arguments";
  65. ShouldNotBeThere(1,2,3);
  66. quit;
  67. end;
  68. Fluid '(UndefnCode!* UndefnNarg!*);
  69. syslsp procedure UndefinedFunctionAux;
  70. % Should preserve all regs
  71. <<Terpri();
  72. Prin2String "**** Undefined Function: ";
  73. Prin1ID LispVar UndefnCode!*;
  74. Prin2String " , called with ";
  75. Prin2 LispVar UndefnNarg!*;
  76. Prin2T " arguments";
  77. Quit;>>;
  78. Off syslisp;
  79. End;