1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Maxima 5.47.0 Manual: Functions and Variables for File Input and Output</title>
<meta name="description" content="Maxima 5.47.0 Manual: Functions and Variables for File Input and Output">
<meta name="keywords" content="Maxima 5.47.0 Manual: Functions and Variables for File Input and Output">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="maxima_toc.html#Top" rel="start" title="Top">
<link href="maxima_423.html#Function-and-Variable-Index" rel="index" title="Function and Variable Index">
<link href="maxima_toc.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="maxima_72.html#File-Input-and-Output" rel="up" title="File Input and Output">
<link href="maxima_76.html#Functions-and-Variables-for-TeX-Output" rel="next" title="Functions and Variables for TeX Output">
<link href="maxima_74.html#Files" rel="previous" title="Files">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
body {color: black; background: white; margin-left: 8%; margin-right: 13%;
font-family: "FreeSans", sans-serif}
h1 {font-size: 150%; font-family: "FreeSans", sans-serif}
h2 {font-size: 125%; font-family: "FreeSans", sans-serif}
h3 {font-size: 100%; font-family: "FreeSans", sans-serif}
a[href] {color: rgb(0,0,255); text-decoration: none;}
a[href]:hover {background: rgb(220,220,220);}
div.textbox {border: solid; border-width: thin; padding-top: 1em;
padding-bottom: 1em; padding-left: 2em; padding-right: 2em}
div.titlebox {border: none; padding-top: 1em; padding-bottom: 1em;
padding-left: 2em; padding-right: 2em; background: rgb(200,255,255);
font-family: sans-serif}
div.synopsisbox {
border: none; padding-top: 1em; padding-bottom: 1em; padding-left: 2em;
padding-right: 2em; background: rgb(255,220,255);}
pre.example {border: 1px solid rgb(180,180,180); padding-top: 1em;
padding-bottom: 1em; padding-left: 1em; padding-right: 1em;
background-color: rgb(238,238,255)}
div.spacerbox {border: none; padding-top: 2em; padding-bottom: 2em}
div.image {margin: 0; padding: 1em; text-align: center}
div.categorybox {border: 1px solid gray; padding-top: 1em; padding-bottom: 1em;
padding-left: 1em; padding-right: 1em; background: rgb(247,242,220)}
img {max-width:80%; max-height: 80%; display: block; margin-left: auto; margin-right: auto}
-->
</style>
<link rel="icon" href="figures/favicon.ico">
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6>"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Functions-and-Variables-for-File-Input-and-Output"></a>
<div class="header">
<p>
Next: <a href="maxima_76.html#Functions-and-Variables-for-TeX-Output" accesskey="n" rel="next">Functions and Variables for TeX Output</a>, Previous: <a href="maxima_74.html#Files" accesskey="p" rel="previous">Files</a>, Up: <a href="maxima_72.html#File-Input-and-Output" accesskey="u" rel="up">File Input and Output</a> [<a href="maxima_toc.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="maxima_423.html#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Functions-and-Variables-for-File-Input-and-Output-1"></a>
<h3 class="section">13.3 Functions and Variables for File Input and Output</h3>
<a name="appendfile"></a><a name="Item_003a-Input_002fdeffn_002fappendfile"></a><dl>
<dt><a name="index-appendfile"></a>Function: <strong>appendfile</strong> <em>(<var>filename</var>)</em></dt>
<dd>
<p>Appends a console transcript to <var>filename</var>. <code>appendfile</code> is the same
as <code><a href="#writefile">writefile</a></code>, except that the transcript file, if it exists, is
always appended.
</p>
<p><code><a href="#closefile">closefile</a></code> closes the transcript file opened by <code>appendfile</code> or
<code>writefile</code>.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-output">File output</a>
·<a href="maxima_424.html#Category_003a-Console-interaction">Console interaction</a>
·</div></dd></dl>
<a name="batch"></a><a name="Item_003a-Input_002fdeffn_002fbatch"></a><dl>
<dt><a name="index-batch"></a>Function: <strong>batch</strong> <em><br> <tt>batch</tt> (<var>filename</var>) <br> <tt>batch</tt> (<var>filename</var>, <var>option</var>) <br> <tt>batch</tt> (<var>S</var>) <br> <tt>batch</tt> (<var>S</var>, <var>option</var>)</em></dt>
<dd>
<p><code>batch(<var>filename</var>)</code> reads Maxima expressions from <var>filename</var> and
evaluates them. <code>batch</code> searches for <var>filename</var> in the list
<code><a href="#file_005fsearch_005fmaxima">file_search_maxima</a></code>. See also <code><a href="#file_005fsearch">file_search</a></code>.
</p>
<p><code>batch(<var>S</var>)</code> reads Maxima expressions from the input stream <var>S</var>
as created by <code><a href="maxima_376.html#openr">openr</a></code>.
The behavior of <code>batch</code> in this case is the same as if the input
were a file name, and in the remainder of this description,
what is said about input files applies to input streams as well,
except that the comments about searching for files do not apply to streams.
</p>
<p><code>batch(<var>filename</var>, <code>demo</code>)</code> is like <code>demo(<var>filename</var>)</code>.
In this case <code>batch</code> searches for <var>filename</var> in the list
<code><a href="#file_005fsearch_005fdemo">file_search_demo</a></code>. See <code><a href="maxima_5.html#demo">demo</a></code>.
</p>
<p><code>batch(<var>filename</var>, <code>test</code>)</code> is like <code><a href="maxima_2.html#run_005ftestsuite">run_testsuite</a></code> with the
option <code>display_all=true</code>. For this case <code>batch</code> searches
<var>filename</var> in the list <code>file_search_maxima</code> and not in the list
<code><a href="#file_005fsearch_005ftests">file_search_tests</a></code> like <code>run_testsuite</code>. Furthermore,
<code>run_testsuite</code> runs tests which are in the list
<code><a href="maxima_2.html#testsuite_005ffiles">testsuite_files</a></code>. With <code>batch</code> it is possible to run any file in
a test mode, which can be found in the list <code>file_search_maxima</code>. This is
useful, when writing a test file.
</p>
<p><var>filename</var> comprises a sequence of Maxima expressions, each terminated with
<code>;</code> or <code>$</code>. The special variable <code><a href="maxima_8.html#g_t_0025">%</a></code> and the function
<code><a href="maxima_8.html#g_t_0025th">%th</a></code> refer to previous results within the file. The file may include
<code>:lisp</code> constructs. Spaces, tabs, and newlines in the file are ignored.
A suitable input file may be created by a text editor or by the
<code><a href="#stringout">stringout</a></code> function.
</p>
<p><code>batch</code> reads each input expression from <var>filename</var>, displays the input
to the console, computes the corresponding output expression, and displays the
output expression. Input labels are assigned to the input expressions and
output labels are assigned to the output expressions. <code>batch</code> evaluates
every input expression in the file unless there is an error. If user input is
requested (by <code><a href="maxima_63.html#asksign">asksign</a></code> or <code><a href="maxima_63.html#askinteger">askinteger</a></code>, for example) <code>batch</code>
pauses to collect the requisite input and then continue.
</p>
<p>It may be possible to halt <code>batch</code> by typing <code>control-C</code> at the
console. The effect of <code>control-C</code> depends on the underlying Lisp
implementation.
</p>
<p><code>batch</code> has several uses, such as to provide a reservoir for working
command lines, to give error-free demonstrations, or to help organize one’s
thinking in solving complex problems.
</p>
<p><code>batch</code> evaluates its arguments.
</p>
<p>When called with no second argument or with the option <code>demo</code>,
<code>batch</code> returns the path of <var>filename</var>,
if the argument is a file name,
or the path of the file for which the input stream was opened,
if the argument is a file input stream.
If the argument is a string input stream,
a representation of the input stream is returned.
</p>
<p>When called with the option <code>test</code>, the return value
is a an empty list <code>[]</code> or a list with <var>filename</var> and the numbers of
the tests which have failed.
</p>
<p>See also <code><a href="#load">load</a></code>, <code><a href="#batchload">batchload</a></code>, and <code><a href="maxima_5.html#demo">demo</a></code>.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Session-management">Session management</a>
·<a href="maxima_424.html#Category_003a-File-input">File input</a>
·</div></dd></dl>
<a name="batchload"></a><a name="Item_003a-Input_002fdeffn_002fbatchload"></a><dl>
<dt><a name="index-batchload"></a>Function: <strong>batchload</strong> <em><br> <tt>batchload</tt> (<var>filename</var>) <br> <tt>batchload</tt> (<var>S</var>) </em></dt>
<dd><p>Reads Maxima expressions from input file <var>filename</var> or input stream <var>S</var>
and evaluates them,
without displaying the input or output expressions and without assigning labels to
output expressions. Printed output (such as produced by <code><a href="maxima_9.html#print">print</a></code> or
<code><a href="maxima_5.html#describe">describe</a></code>)) is displayed, however.
</p>
<p>The special variable <code><a href="maxima_8.html#g_t_0025">%</a></code> and the function <code><a href="maxima_8.html#g_t_0025th">%th</a></code> refer to previous
results from the interactive interpreter, not results within the file.
The file cannot include <code>:lisp</code> constructs.
</p>
<p><code>batchload</code> evaluates its argument.
</p>
<p><code>batchload</code> returns the path of <var>filename</var>,
if the argument is a file name,
or the path of the file for which the input stream was opened,
if the argument is a file input stream.
If the argument is a string input stream,
a representation of the input stream is returned.
</p>
<p>See also <code><a href="#batch">batch</a></code>, and <code><a href="#load">load</a></code>.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Session-management">Session management</a>
·<a href="maxima_424.html#Category_003a-File-input">File input</a>
·</div></dd></dl>
<a name="closefile"></a><a name="Item_003a-Input_002fdeffn_002fclosefile"></a><dl>
<dt><a name="index-closefile"></a>Function: <strong>closefile</strong> <em>()</em></dt>
<dd>
<p>Closes the transcript file opened by <code><a href="#writefile">writefile</a></code> or <code><a href="#appendfile">appendfile</a></code>.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-output">File output</a>
·<a href="maxima_424.html#Category_003a-Console-interaction">Console interaction</a>
·</div></dd></dl>
<a name="file_005foutput_005fappend"></a><a name="Item_003a-Input_002fdefvr_002ffile_005foutput_005fappend"></a><dl>
<dt><a name="index-file_005foutput_005fappend"></a>Option variable: <strong>file_output_append</strong></dt>
<dd><p>Default value: <code>false</code>
</p>
<p><code>file_output_append</code> governs whether file output functions append or
truncate their output file. When <code>file_output_append</code> is <code>true</code>, such
functions append to their output file. Otherwise, the output file is truncated.
</p>
<p><code><a href="#save">save</a></code>, <code><a href="#stringout">stringout</a></code>, and <code><a href="#with_005fstdout">with_stdout</a></code> respect
<code>file_output_append</code>. Other functions which write output files do not
respect <code>file_output_append</code>. In particular, plotting and translation
functions always truncate their output file, and <code><a href="maxima_76.html#tex">tex</a></code> and
<code><a href="#appendfile">appendfile</a></code> always append.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-output">File output</a>
·<a href="maxima_424.html#Category_003a-Global-flags">Global flags</a>
·</div></dd></dl>
<a name="filename_005fmerge"></a><a name="Item_003a-Input_002fdeffn_002ffilename_005fmerge"></a><dl>
<dt><a name="index-filename_005fmerge"></a>Function: <strong>filename_merge</strong> <em>(<var>path</var>, <var>filename</var>)</em></dt>
<dd>
<p>Constructs a modified path from <var>path</var> and <var>filename</var>. If the final
component of <var>path</var> is of the form <code>###.<var>something</var></code>, the component
is replaced with <code><var>filename</var>.<var>something</var></code>. Otherwise, the final
component is simply replaced by <var>filename</var>.
</p>
<p>The result is a Lisp pathname object.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-input">File input</a>
·<a href="maxima_424.html#Category_003a-File-output">File output</a>
·</div></dd></dl>
<a name="file_005fsearch"></a><a name="Item_003a-Input_002fdeffn_002ffile_005fsearch"></a><dl>
<dt><a name="index-file_005fsearch"></a>Function: <strong>file_search</strong> <em><br> <tt>file_search</tt> (<var>filename</var>) <br> <tt>file_search</tt> (<var>filename</var>, <var>pathlist</var>)</em></dt>
<dd>
<p><code>file_search</code> searches for the file <var>filename</var> and returns the path to
the file (as a string) if it can be found; otherwise <code>file_search</code> returns
<code>false</code>. <code>file_search (<var>filename</var>)</code> searches in the default
search directories, which are specified by the
<code><a href="#file_005fsearch_005fmaxima">file_search_maxima</a></code>, <code><a href="#file_005fsearch_005flisp">file_search_lisp</a></code>, and
<code><a href="#file_005fsearch_005fdemo">file_search_demo</a></code> variables.
</p>
<p><code>file_search</code> first checks if the actual name passed exists,
before attempting to match it to “wildcard” file search patterns.
See <code><a href="#file_005fsearch_005fmaxima">file_search_maxima</a></code> concerning file search patterns.
</p>
<p>The argument <var>filename</var> can be a path and file name, or just a file name,
or, if a file search directory includes a file search pattern, just the base of
the file name (without an extension). For example,
</p>
<div class="example">
<pre class="example">file_search ("/home/wfs/special/zeta.mac");
file_search ("zeta.mac");
file_search ("zeta");
</pre></div>
<p>all find the same file, assuming the file exists and
<code>/home/wfs/special/###.mac</code> is in <code>file_search_maxima</code>.
</p>
<p><code>file_search (<var>filename</var>, <var>pathlist</var>)</code> searches only in the
directories specified by <var>pathlist</var>, which is a list of strings. The
argument <var>pathlist</var> supersedes the default search directories, so if the
path list is given, <code>file_search</code> searches only the ones specified, and not
any of the default search directories. Even if there is only one directory in
<var>pathlist</var>, it must still be given as an one-element list.
</p>
<p>The user may modify the default search directories.
See <code><a href="#file_005fsearch_005fmaxima">file_search_maxima</a></code>.
</p>
<p><code>file_search</code> is invoked by <code><a href="#load">load</a></code> with <code>file_search_maxima</code> and
<code><a href="#file_005fsearch_005flisp">file_search_lisp</a></code> as the search directories.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-input">File input</a>
·</div></dd></dl>
<a name="file_005fsearch_005fmaxima"></a><a name="file_005fsearch_005flisp"></a><a name="file_005fsearch_005fdemo"></a><a name="file_005fsearch_005fusage"></a><a name="file_005fsearch_005ftests"></a><a name="Item_003a-Input_002fdefvr_002ffile_005fsearch_005fmaxima"></a><dl>
<dt><a name="index-file_005fsearch_005fmaxima"></a>Option variable: <strong>file_search_maxima</strong></dt>
<dd><a name="Item_003a-Input_002fdefvr_002ffile_005fsearch_005flisp"></a></dd><dt><a name="index-file_005fsearch_005flisp"></a>Option variable: <strong>file_search_lisp</strong></dt>
<dd><a name="Item_003a-Input_002fdefvr_002ffile_005fsearch_005fdemo"></a></dd><dt><a name="index-file_005fsearch_005fdemo"></a>Option variable: <strong>file_search_demo</strong></dt>
<dd><a name="Item_003a-Input_002fdefvr_002ffile_005fsearch_005fusage"></a></dd><dt><a name="index-file_005fsearch_005fusage"></a>Option variable: <strong>file_search_usage</strong></dt>
<dd><a name="Item_003a-Input_002fdefvr_002ffile_005fsearch_005ftests"></a></dd><dt><a name="index-file_005fsearch_005ftests"></a>Option variable: <strong>file_search_tests</strong></dt>
<dd>
<p>These variables specify lists of directories to be searched by
<code><a href="#load">load</a></code>, <code><a href="maxima_5.html#demo">demo</a></code>, and some other Maxima functions. The default
values of these variables name various directories in the Maxima installation.
</p>
<p>The user can modify these variables, either to replace the default values or to
append additional directories. For example,
</p>
<div class="example">
<pre class="example">file_search_maxima: ["/usr/local/foo/###.mac",
"/usr/local/bar/###.mac"]$
</pre></div>
<p>replaces the default value of <code>file_search_maxima</code>, while
</p>
<div class="example">
<pre class="example">file_search_maxima: append (file_search_maxima,
["/usr/local/foo/###.mac", "/usr/local/bar/###.mac"])$
</pre></div>
<p>appends two additional directories. It may be convenient to put such an
expression in the file <code>maxima-init.mac</code> so that the file search path is
assigned automatically when Maxima starts.
See also <a href="maxima_153.html#Introduction-for-Runtime-Environment">Introduction for Runtime Environment</a>.
</p>
<p>Multiple filename extensions and multiple paths can be specified by special
“wildcard” constructions. The string <code>###</code> expands into the sought-after
name, while a comma-separated list enclosed in curly braces
<code>{foo,bar,baz}</code> expands into multiple strings. For example, supposing
the sought-after name is <code>neumann</code>,
</p>
<div class="example">
<pre class="example">"/home/{wfs,gcj}/###.{lisp,mac}"
</pre></div>
<p align="left">expands into <code>/home/wfs/neumann.lisp</code>, <code>/home/gcj/neumann.lisp</code>,
<code>/home/wfs/neumann.mac</code>, and <code>/home/gcj/neumann.mac</code>.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-input">File input</a>
·<a href="maxima_424.html#Category_003a-Global-variables">Global variables</a>
·</div></dd></dl>
<a name="file_005ftype"></a><a name="Item_003a-Input_002fdeffn_002ffile_005ftype"></a><dl>
<dt><a name="index-file_005ftype"></a>Function: <strong>file_type</strong> <em>(<var>filename</var>)</em></dt>
<dd>
<p>Returns a guess about the content of <var>filename</var>, based on the filename
extension. <var>filename</var> need not refer to an actual file; no attempt is made
to open the file and inspect the content.
</p>
<p>The return value is a symbol, either <code>object</code>, <code>lisp</code>, or
<code>maxima</code>. If the extension is matches one of the values in
<code>file_type_maxima</code>, <code>file_type</code> returns <code>maxima</code>. If the
extension matches one of the values in <code>file_type_lisp</code>, <code>file_type</code>
returns <code>lisp</code>. If none of the above, <code>file_type</code> returns
<code>object</code>.
</p>
<p>See also <code><a href="#pathname_005ftype">pathname_type</a></code>.
</p>
<p>See <code><a href="#file_005ftype_005fmaxima">file_type_maxima</a></code> and <code><a href="#file_005ftype_005flisp">file_type_lisp</a></code> for the default values.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">(%i2) map('file_type,
["test.lisp", "test.mac", "test.dem", "test.txt"]);
(%o2) [lisp, maxima, maxima, object]
</pre></div>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-input">File input</a>
·</div></dd></dl>
<a name="file_005ftype_005flisp"></a><a name="Item_003a-Input_002fdefvr_002ffile_005ftype_005flisp"></a><dl>
<dt><a name="index-file_005ftype_005flisp"></a>Option variable: <strong>file_type_lisp</strong></dt>
<dd><p>Default value: <code>[l, lsp, lisp]</code>
</p>
<p><code>file_type_lisp</code> is a list of file extensions that maxima recognizes
as denoting a Lisp source file.
</p>
<p>See also <code><a href="#file_005ftype">file_type</a></code>.
</p></dd></dl>
<a name="file_005ftype_005fmaxima"></a><a name="Item_003a-Input_002fdefvr_002ffile_005ftype_005fmaxima"></a><dl>
<dt><a name="index-file_005ftype_005fmaxima"></a>Option variable: <strong>file_type_maxima</strong></dt>
<dd><p>Default value: <code>[mac, mc, demo, dem, dm1, dm2, dm3, dmt, wxm]</code>
</p>
<p><code>file_type_maxima</code> is a list of file extensions that maxima recognizes
as denoting a Maxima source file.
</p>
<p>See also <code><a href="#file_005ftype">file_type</a></code>.
</p></dd></dl>
<a name="load"></a><a name="Item_003a-Input_002fdeffn_002fload"></a><dl>
<dt><a name="index-load"></a>Function: <strong>load</strong> <em>(<var>filename</var>)</em></dt>
<dd>
<p>Evaluates expressions in <var>filename</var>, thus bringing variables, functions, and
other objects into Maxima. The binding of any existing object is clobbered by
the binding recovered from <var>filename</var>.
</p>
<p><var>filename</var> must be a string, symbol,
or Lisp pathname (as created by <code><a href="#filename_005fmerge">filename_merge</a></code>).
To find the file, <code>load</code> calls
<code><a href="#file_005fsearch">file_search</a></code> with <code><a href="#file_005fsearch_005fmaxima">file_search_maxima</a></code> and
<code><a href="#file_005fsearch_005flisp">file_search_lisp</a></code> as the search directories. If <code>load</code> succeeds, it
returns the name of the file. Otherwise <code>load</code> prints an error message.
</p>
<p><code>load</code> works equally well for Lisp code and Maxima code. Files created by
<code><a href="#save">save</a></code>, <code><a href="maxima_170.html#translate_005ffile">translate_file</a></code>, and <code><a href="maxima_170.html#compile_005ffile">compile_file</a></code>, which
create Lisp code, and <code><a href="#stringout">stringout</a></code>, which creates Maxima code, can all
be processed by <code>load</code>. <code>load</code> calls <code><a href="#loadfile">loadfile</a></code> to load Lisp
files and <code><a href="#batchload">batchload</a></code> to load Maxima files.
</p>
<p><code>load</code> does not recognize <code>:lisp</code> constructs in Maxima files, and
while processing <var>filename</var>, the global variables <code>_</code>, <code>__</code>,
<code>%</code>, and <code>%th</code> have whatever bindings they had when <code>load</code> was
called.
</p>
<p>Note also that structures will only be read back as structures if
they have been defined by <code>defstruct</code> before the <code>load</code> command
is called.
</p>
<p>See also <code><a href="#loadfile">loadfile</a></code>, for Lisp files; and <code><a href="#batch">batch</a></code>, <code><a href="#batchload">batchload</a></code>, and
<code><a href="maxima_5.html#demo">demo</a></code>. for Maxima files.
</p>
<p>See <code><a href="#file_005fsearch">file_search</a></code> for more detail about the file search mechanism.
The <code><a href="maxima_321.html#numericalio">numericalio</a></code> chapter describes many functions
for loading csv and other data files.
</p>
<p>During Maxima file loading, the variable <code><a href="#load_005fpathname">load_pathname</a></code> is bound to the pathname of the file
being loaded.
</p>
<p><code>load</code> evaluates its argument.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Session-management">Session management</a>
·<a href="maxima_424.html#Category_003a-File-input">File input</a>
·</div></dd></dl>
<a name="load_005fpathname"></a><a name="Item_003a-Input_002fdefvr_002fload_005fpathname"></a><dl>
<dt><a name="index-load_005fpathname"></a>System variable: <strong>load_pathname</strong></dt>
<dd><p>Default value: <code>false</code>
</p>
<p>When a file is loaded with the functions <code><a href="#load">load</a></code>, <code><a href="#loadfile">loadfile</a></code> or
<code><a href="#batchload">batchload</a></code> the system variable <code>load_pathname</code> is bound to the
pathname of the file which is processed.
</p>
<p>The variable <code>load_pathname</code> can be accessed from the file during the
loading.
</p>
<p>Example:
</p>
<p>Suppose we have a batchfile <code>test.mac</code> in the directory
</p><p align="left"><code>"/home/dieter/workspace/mymaxima/temp/"</code> with the following commands
</p>
<div class="example">
<pre class="example">print("The value of load_pathname is: ", load_pathname)$
print("End of batchfile")$
</pre></div>
<p>then we get the following output
</p>
<div class="example">
<pre class="example">(%i1) load("/home/dieter/workspace/mymaxima/temp/test.mac")$
The value of load_pathname is:
/home/dieter/workspace/mymaxima/temp/test.mac
End of batchfile
</pre></div>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-input">File input</a>
·</div></dd></dl>
<a name="loadfile"></a><a name="Item_003a-Input_002fdeffn_002floadfile"></a><dl>
<dt><a name="index-loadfile"></a>Function: <strong>loadfile</strong> <em>(<var>filename</var>)</em></dt>
<dd>
<p>Evaluates Lisp expressions in <var>filename</var>. <code>loadfile</code> does not invoke
<code><a href="#file_005fsearch">file_search</a></code>, so <code>filename</code> must include the file extension and
as much of the path as needed to find the file.
</p>
<p><code>loadfile</code> can process files created by <code><a href="#save">save</a></code>,<!-- /@w -->
<code><a href="maxima_170.html#translate_005ffile">translate_file</a></code>, and <code><a href="maxima_170.html#compile_005ffile">compile_file</a></code>. The user may find it
more convenient to use <code><a href="#load">load</a></code> instead of <code>loadfile</code>.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Session-management">Session management</a>
·<a href="maxima_424.html#Category_003a-File-input">File input</a>
·</div></dd></dl>
<a name="loadprint"></a><a name="Item_003a-Input_002fdefvr_002floadprint"></a><dl>
<dt><a name="index-loadprint"></a>Option variable: <strong>loadprint</strong></dt>
<dd><p>Default value: <code>true</code>
</p>
<p><code>loadprint</code> tells whether to print a message when a file is loaded.
</p>
<ul>
<li> When <code>loadprint</code> is <code>true</code>, always print a message.
</li><li> When <code>loadprint</code> is <code>'loadfile</code>, print a message only if
a file is loaded by the function <code>loadfile</code>.
</li><li> When <code>loadprint</code> is <code>'autoload</code>,
print a message only if a file is automatically loaded.
See <code><a href="maxima_159.html#setup_005fautoload">setup_autoload</a></code>.
</li><li> When <code>loadprint</code> is <code>false</code>, never print a message.
</li></ul>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-input">File input</a>
·<a href="maxima_424.html#Category_003a-Global-flags">Global flags</a>
·</div></dd></dl>
<a name="directory"></a><a name="Item_003a-Input_002fdeffn_002fdirectory"></a><dl>
<dt><a name="index-directory"></a>Function: <strong>directory</strong> <em>(<var>path</var>)</em></dt>
<dd>
<p>Returns a list of the files and directories found in <var>path</var>
in the file system.
</p>
<p><var>path</var> may contain wildcard characters (i.e., characters which represent
unspecified parts of the path),
which include at least the asterisk on most systems,
and possibly other characters, depending on the system.
</p>
<p><code>directory</code> relies on the Lisp function DIRECTORY,
which may have implementation-specific behavior.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-input">File input</a>
·</div></dd></dl>
<a name="pathname_005fdirectory"></a><a name="pathname_005fname"></a><a name="pathname_005ftype"></a><a name="Item_003a-Input_002fdeffn_002fpathname_005fdirectory"></a><dl>
<dt><a name="index-pathname_005fdirectory"></a>Function: <strong>pathname_directory</strong> <em>(<var>pathname</var>)</em></dt>
<dd><a name="Item_003a-Input_002fdeffn_002fpathname_005fname"></a></dd><dt><a name="index-pathname_005fname"></a>Function: <strong>pathname_name</strong> <em>(<var>pathname</var>)</em></dt>
<dd><a name="Item_003a-Input_002fdeffn_002fpathname_005ftype"></a></dd><dt><a name="index-pathname_005ftype"></a>Function: <strong>pathname_type</strong> <em>(<var>pathname</var>)</em></dt>
<dd>
<p>These functions return the components of <var>pathname</var>.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">(%i1) pathname_directory("/home/dieter/maxima/changelog.txt");
(%o1) /home/dieter/maxima/
(%i2) pathname_name("/home/dieter/maxima/changelog.txt");
(%o2) changelog
(%i3) pathname_type("/home/dieter/maxima/changelog.txt");
(%o3) txt
</pre></div>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-input">File input</a>
·</div></dd></dl>
<a name="printfile"></a><a name="Item_003a-Input_002fdeffn_002fprintfile"></a><dl>
<dt><a name="index-printfile"></a>Function: <strong>printfile</strong> <em>(<var>path</var>)</em></dt>
<dd>
<p>Prints the file named by <var>path</var> to the console. <var>path</var> may be a string
or a symbol; if it is a symbol, it is converted to a string.
</p>
<p>If <var>path</var> names a file which is accessible from the current working
directory, that file is printed to the console. Otherwise, <code>printfile</code>
attempts to locate the file by appending <var>path</var> to each of the elements of
<code><a href="#file_005fsearch_005fusage">file_search_usage</a></code> via <code><a href="#filename_005fmerge">filename_merge</a></code>.
</p>
<p><code>printfile</code> returns <var>path</var> if it names an existing file,
or otherwise the result of a successful filename merge.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-input">File input</a>
·<a href="maxima_424.html#Category_003a-Console-interaction">Console interaction</a>
·</div></dd></dl>
<a name="save"></a><a name="Item_003a-Input_002fdeffn_002fsave"></a><dl>
<dt><a name="index-save"></a>Function: <strong>save</strong> <em><br> <tt>save</tt> (<var>filename</var>, <var>name_1</var>, <var>name_2</var>, <var>name_3</var>, …) <br> <tt>save</tt> (<var>filename</var>, values, functions, labels, …) <br> <tt>save</tt> (<var>filename</var>, [<var>m</var>, <var>n</var>]) <br> <tt>save</tt> (<var>filename</var>, <var>name_1</var>=<var>expr_1</var>, …) <br> <tt>save</tt> (<var>filename</var>, all) <br> <tt>save</tt> (<var>filename</var>, <var>name_1</var>=<var>expr_1</var>, <var>name_2</var>=<var>expr_2</var>, …)</em></dt>
<dd>
<p>Stores the current values of <var>name_1</var>, <var>name_2</var>, <var>name_3</var>, …,
in <var>filename</var>. The arguments are the names of variables, functions, or
other objects. If a name has no value or function associated with it, it is
ignored. <code>save</code> returns <var>filename</var>.
</p>
<p><code>save</code> stores data in the form of Lisp expressions.
If <var>filename</var> ends in <code>.lisp</code> the
data stored by <code>save</code> may be recovered by <code>load (<var>filename</var>)</code>.
See <code><a href="#load">load</a></code>.
</p>
<p>The global flag <code><a href="#file_005foutput_005fappend">file_output_append</a></code> governs whether <code>save</code> appends or
truncates the output file. When <code>file_output_append</code> is <code>true</code>,
<code>save</code> appends to the output file. Otherwise, <code>save</code> truncates the
output file. In either case, <code>save</code> creates the file if it does not yet
exist.
</p>
<p>The special form <code>save (<var>filename</var>, values, functions, labels, ...)</code>
stores the items named by <code><a href="maxima_8.html#values">values</a></code>, <code><a href="maxima_170.html#functions">functions</a></code>,<!-- /@w -->
<code><a href="maxima_8.html#labels">labels</a></code>, etc. The names may be any specified by the variable
<code><a href="maxima_8.html#infolists">infolists</a></code>. <code>values</code> comprises all user-defined variables.
</p>
<p>The special form <code>save (<var>filename</var>, [<var>m</var>, <var>n</var>])</code> stores the
values of input and output labels <var>m</var> through <var>n</var>. Note that <var>m</var>
and <var>n</var> must be literal integers. Input and output labels may also be
stored one by one, e.g., <code>save ("foo.1", %i42, %o42)</code>.
<code>save (<var>filename</var>, labels)</code> stores all input and output labels.
When the stored labels are recovered, they clobber existing labels.
</p>
<p>The special form <code>save (<var>filename</var>, <var>name_1</var>=<var>expr_1</var>,
<var>name_2</var>=<var>expr_2</var>, ...)</code> stores the values of <var>expr_1</var>,
<var>expr_2</var>, …, with names <var>name_1</var>, <var>name_2</var>, …
It is useful to apply this form to input and output labels, e.g.,
<code>save ("foo.1", aa=%o88)</code>. The right-hand side of the equality in this
form may be any expression, which is evaluated. This form does not introduce
the new names into the current Maxima environment, but only stores them in
<var>filename</var>.
</p>
<p>These special forms and the general form of <code>save</code> may be mixed at will.
For example, <code>save (<var>filename</var>, aa, bb, cc=42, functions, [11, 17])</code>.
</p>
<p>The special form <code>save (<var>filename</var>, all)</code> stores the current state of
Maxima. This includes all user-defined variables, functions, arrays, etc., as
well as some automatically defined items. The saved items include system
variables, such as <code><a href="#file_005fsearch_005fmaxima">file_search_maxima</a></code> or <code><a href="maxima_8.html#showtime">showtime</a></code>, if they
have been assigned new values by the user; see <code><a href="maxima_8.html#myoptions">myoptions</a></code>.
</p>
<p><code>save</code> evaluates <var>filename</var> and quotes all other arguments.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Session-management">Session management</a>
·<a href="maxima_424.html#Category_003a-File-output">File output</a>
·</div></dd></dl>
<a name="stringout"></a><a name="Item_003a-Input_002fdeffn_002fstringout"></a><dl>
<dt><a name="index-stringout"></a>Function: <strong>stringout</strong> <em><br> <tt>stringout</tt> (<var>filename</var>, <var>expr_1</var>, <var>expr_2</var>, <var>expr_3</var>, …) <br> <tt>stringout</tt> (<var>filename</var>, [<var>m</var>, <var>n</var>]) <br> <tt>stringout</tt> (<var>filename</var>, input) <br> <tt>stringout</tt> (<var>filename</var>, functions) <br> <tt>stringout</tt> (<var>filename</var>, values)</em></dt>
<dd>
<p><code>stringout</code> writes expressions to a file in the same form the expressions
would be typed for input. The file can then be used as input for the
<code><a href="#batch">batch</a></code> or <code><a href="maxima_5.html#demo">demo</a></code> commands, and it may be edited for any purpose.
<code>stringout</code> can be executed while <code><a href="#writefile">writefile</a></code> is in progress.
</p>
<p>The global flag <code><a href="#file_005foutput_005fappend">file_output_append</a></code> governs whether <code>stringout</code>
appends or truncates the output file. When <code>file_output_append</code> is
<code>true</code>, <code>stringout</code> appends to the output file. Otherwise,
<code>stringout</code> truncates the output file. In either case, <code>stringout</code>
creates the file if it does not yet exist.
</p>
<p>The general form of <code>stringout</code> writes the values of one or more
expressions to the output file. Note that if an expression is a
variable, only the value of the variable is written and not the name
of the variable. As a useful special case, the expressions may be
input labels (<code>%i1</code>, <code>%i2</code>, <code>%i3</code>, …) or output labels
(<code>%o1</code>, <code>%o2</code>, <code>%o3</code>, …).
</p>
<p>If <code><a href="maxima_9.html#grind">grind</a></code> is <code>true</code>, <code>stringout</code> formats the output using the
<code>grind</code> format. Otherwise the <code>string</code> format is used. See
<code>grind</code> and <code>string</code>.
</p>
<p>The special form <code>stringout (<var>filename</var>, [<var>m</var>, <var>n</var>])</code> writes
the values of input labels m through n, inclusive.
</p>
<p>The special form <code>stringout (<var>filename</var>, input)</code> writes all
input labels to the file.
</p>
<p>The special form <code>stringout (<var>filename</var>, functions)</code> writes all
user-defined functions (named by the global list <code><a href="maxima_170.html#functions">functions</a></code>)) to the
file.
</p>
<p>The special form <code>stringout (<var>filename</var>, values)</code> writes all
user-assigned variables (named by the global list <code><a href="maxima_8.html#values">values</a></code>)) to the file.
Each variable is printed as an assignment statement, with the name of the
variable, a colon, and its value. Note that the general form of
<code>stringout</code> does not print variables as assignment statements.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-Session-management">Session management</a>
·<a href="maxima_424.html#Category_003a-File-output">File output</a>
·</div></dd></dl>
<a name="with_005fstdout"></a><a name="Item_003a-Input_002fdeffn_002fwith_005fstdout"></a><dl>
<dt><a name="index-with_005fstdout"></a>Function: <strong>with_stdout</strong> <em><br> <tt>with_stdout</tt> (<var>f</var>, <var>expr_1</var>, <var>expr_2</var>, <var>expr_3</var>, …) <br> <tt>with_stdout</tt> (<var>s</var>, <var>expr_1</var>, <var>expr_2</var>, <var>expr_3</var>, …)</em></dt>
<dd>
<p>Evaluates <var>expr_1</var>, <var>expr_2</var>, <var>expr_3</var>, … and writes any
output thus generated to a file <var>f</var> or output stream <var>s</var>. The evaluated
expressions are not written to the output. Output may be generated by
<code><a href="maxima_9.html#print">print</a></code>, <code><a href="maxima_9.html#display">display</a></code>, <code><a href="maxima_9.html#grind">grind</a></code>, among other functions.
</p>
<p>The global flag <code><a href="#file_005foutput_005fappend">file_output_append</a></code> governs whether <code>with_stdout</code>
appends or truncates the output file <var>f</var>. When <code>file_output_append</code>
is <code>true</code>, <code>with_stdout</code> appends to the output file. Otherwise,
<code>with_stdout</code> truncates the output file. In either case,
<code>with_stdout</code> creates the file if it does not yet exist.
</p>
<p><code>with_stdout</code> returns the value of its final argument.
</p>
<p>See also <code><a href="#writefile">writefile</a></code> and <code><a href="maxima_9.html#display2d">display2d</a></code>.
</p>
<div class="example">
<pre class="example">(%i1) with_stdout ("tmp.out", for i:5 thru 10 do
print (i, "! yields", i!))$
(%i2) printfile ("tmp.out")$
5 ! yields 120
6 ! yields 720
7 ! yields 5040
8 ! yields 40320
9 ! yields 362880
10 ! yields 3628800
</pre></div>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-output">File output</a>
·</div></dd></dl>
<a name="writefile"></a><a name="Item_003a-Input_002fdeffn_002fwritefile"></a><dl>
<dt><a name="index-writefile"></a>Function: <strong>writefile</strong> <em>(<var>filename</var>)</em></dt>
<dd>
<p>Begins writing a transcript of the Maxima session to <var>filename</var>.
All interaction between the user and Maxima is then recorded in this file,
just as it appears on the console.
</p>
<p>As the transcript is printed in the console output format, it cannot be reloaded
into Maxima. To make a file containing expressions which can be reloaded,
see <code><a href="#save">save</a></code> and <code><a href="#stringout">stringout</a></code>. <code>save</code> stores expressions in Lisp
form, while <code>stringout</code> stores expressions in Maxima form.
</p>
<p>The effect of executing <code>writefile</code> when <var>filename</var> already exists
depends on the underlying Lisp implementation; the transcript file may be
clobbered, or the file may be appended. <code><a href="#appendfile">appendfile</a></code> always appends to
the transcript file.
</p>
<p>It may be convenient to execute <code><a href="maxima_8.html#playback">playback</a></code> after <code>writefile</code> to save
the display of previous interactions. As <code>playback</code> displays only the
input and output variables (<code>%i1</code>, <code>%o1</code>, etc.), any output generated
by a print statement in a function (as opposed to a return value) is not
displayed by <code>playback</code>.
</p>
<p><code><a href="#closefile">closefile</a></code> closes the transcript file opened by <code>writefile</code> or
<code>appendfile</code>.
</p>
<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-File-output">File output</a>
·<a href="maxima_424.html#Category_003a-Console-interaction">Console interaction</a>
·</div></dd></dl>
<a name="Item_003a-Input_002fnode_002fFunctions-and-Variables-for-TeX-Output"></a><hr>
<div class="header">
<p>
Next: <a href="maxima_76.html#Functions-and-Variables-for-TeX-Output" accesskey="n" rel="next">Functions and Variables for TeX Output</a>, Previous: <a href="maxima_74.html#Files" accesskey="p" rel="previous">Files</a>, Up: <a href="maxima_72.html#File-Input-and-Output" accesskey="u" rel="up">File Input and Output</a> [<a href="maxima_toc.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="maxima_423.html#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|