io.tex 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. \section{Input and Output}
  2. \begin{Command}{IN}
  3. \index{input}
  4. The \name{in} command takes a list of file names and inputs each file into
  5. the system.
  6. \begin{Syntax}
  7. \name{in} \meta{filename}\{,\meta{filename}\}\optional
  8. \end{Syntax}
  9. \meta{filename} must be in the current directory, or be a valid pathname.
  10. If the file name is not an identifier, double quote marks (\name{"}) are
  11. needed around the file name.
  12. \begin{Comments}
  13. A message is given if the file cannot be found, or has a mistake
  14. in it.
  15. Ending the command with a semicolon causes the file to be echoed to the
  16. screen; ending it with a dollar sign does not echo the file. If you want
  17. some but not all of a file echoed, turn the switch \nameref{echo} on or off
  18. in the file.
  19. An efficient way to develop procedures in REDUCE is to write them into a file
  20. using a system editor of your choice, and then input the
  21. files into an active REDUCE session. REDUCE reparses the procedure as
  22. it takes information from the file, overwriting the previous procedure
  23. definition. When it accepts the procedure, it echoes its name to the screen.
  24. Data can also be input to the system from files.
  25. Files to be read in should always end in \nameref{end}\name{;} to avoid
  26. end-of-file problems. Note that this is an additional \name{end;} to any
  27. ending procedures in the file.
  28. \end{Comments}
  29. \end{Command}
  30. \begin{Command}{INPUT}
  31. \index{interactive}
  32. The \name{input} command returns the input expression to the REDUCE numbered
  33. prompt that is its argument.
  34. \begin{Syntax}
  35. \name{input}\(\meta{number}\) or \name{input} \meta{number}
  36. \end{Syntax}
  37. \meta{number} must be between 1 and the current REDUCE prompt number.
  38. %%%\begin{Examples}
  39. %%%\explanation{(In the following examples, unlike most others, the numbered
  40. %%%prompt is shown.)}
  41. %%%\end{Examples}
  42. \begin{Comments}
  43. An expression brought back by \name{input} can be reexecuted with new
  44. values or switch settings, or used as an argument in another expression.
  45. The command \nameref{ws} brings back the results of a numbered REDUCE
  46. statement. Two lists contain every input and every output statement since
  47. the beginning of the session. If your session is very long, storage space
  48. begins to fill up with these expressions, so it is a good idea to end the
  49. session once in a while, saving needed expressions to files with the
  50. \nameref{saveas} and \nameref{out} commands.
  51. %%% You can also clear the history lists with the \name{forget} command.
  52. Switch settings and \nameref{let} statements can also be reexecuted by using
  53. \name{input}.
  54. An error message is given if a number is called for that has not yet been used.
  55. \end{Comments}
  56. \end{Command}
  57. \begin{Command}{OUT}
  58. \index{output}\index{open}
  59. The \name{out} command directs output to the filename that is its argument,
  60. until another \name{out} changes the output file, or \nameref{shut} closes it.
  61. \begin{Syntax}
  62. \name{out} \meta{filename} or \name{out "}\meta{pathname} \name{"} or \name{out t}
  63. \end{Syntax}
  64. \meta{filename} must be in the current directory, or be a valid complete
  65. file description for your system. If the file name is not
  66. in the current directory, quote marks are needed around the file name.
  67. If the file already exists, a message is printed allowing you to decide
  68. whether to supersede the contents of the file with new material.
  69. \begin{Comments}
  70. To restore output to the terminal, type \name{out t}, or \nameref{shut} the
  71. file. When you use \name{out t}, the file remains available, and if you
  72. open it again (with another \name{out}), new material is appended rather
  73. than overwriting.
  74. To write a file using \name{out} that can be input at a later time, the
  75. switch \nameref{nat} must be turned off, so that the standard linear form
  76. is saved that can be read in by \nameref{in}. If \name{nat} is on, exponents
  77. are printed on the line above the expression, which causes trouble
  78. when REDUCE tries to read the file.
  79. There is a slight complication if you are using the \name{out} command from
  80. inside a file to create another file. The \nameref{echo} switch is normally
  81. off at the top-level and on while reading files (so you can see what is
  82. being read in). If you create a file using \name{out} at the top-level,
  83. the result lines are printed into the file as you want them. But if you
  84. create such a file from inside a file, the \name{echo} switch is on, and
  85. every line is echoed, first as you typed it, then as REDUCE parsed it, and
  86. then once more for the file. Therefore, when you create a file {\it from}
  87. a file, you need to turn \name{echo} off explicitly before the \name{out}
  88. command, and turn it back on when you \name{shut} the created file, so your
  89. executing file echoes as it should. This behavior also means that as you
  90. watch the file execute, you cannot see the lines that are being put into
  91. the \name{out} file. As soon as you turn \name{echo} on, you can see
  92. output again.
  93. \end{Comments}
  94. \end{Command}
  95. \begin{Command}{SHUT}
  96. \index{output}\index{close}
  97. The \name{shut} command closes output files.
  98. \begin{Syntax}
  99. \name{shut} \meta{filename}\{,\meta{filename}\}\optional
  100. \end{Syntax}
  101. \meta{filename} must have been a file opened by \nameref{out}.
  102. \begin{Comments}
  103. A file that has been opened by \nameref{out} must be \name{shut} before it is
  104. brought in by \nameref{in}. Files that have been opened by \name{out} should
  105. always be \name{shut} before the end of the REDUCE session, to avoid either
  106. loss of information or the printing of extraneous information into the file.
  107. In most systems, terminating a session by \nameref{bye} closes all open
  108. output files.
  109. \end{Comments}
  110. \end{Command}