/usr/share/doc/maxima-doc/html/maxima_13.html is in maxima-doc 5.32.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on January, 10 2014 by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>
-->
<head>
<title>Maxima 5.32.1 Manual: 13. File Input and Output</title>
<meta name="description" content="Maxima 5.32.1 Manual: 13. File Input and Output">
<meta name="keywords" content="Maxima 5.32.1 Manual: 13. File Input and Output">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
body
{
color: black;
background: white;
margin-left: 8%;
margin-right: 13%;
}
h1
{
margin-left: +8%;
font-size: 150%;
font-family: sans-serif
}
h2
{
font-size: 125%;
font-family: sans-serif
}
h3
{
font-size: 100%;
font-family: sans-serif
}
h2,h3,h4,h5,h6 { margin-left: +4%; }
div.textbox
{
border: solid;
border-width: thin;
/* width: 100%; */
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);
/*background: rgb(200,255,255); */
/* font-family: fixed */
}
pre.example
{
border: 1px solid gray;
padding-top: 1em;
padding-bottom: 1em;
padding-left: 1em;
padding-right: 1em;
/* background: rgb(247,242,180); */ /* kind of sandy */
/* background: rgb(200,255,255); */ /* sky blue */
background-color: #F1F5F9; /* light blue-gray */
/* font-family: "Lucida Console", monospace */
}
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: 0px;
padding-bottom: 0px;
padding-left: 1em;
padding-right: 1em;
background: rgb(247,242,220);
}
-->
</style>
<link rel="icon" href="http://maxima.sourceforge.net/favicon.ico"/>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="File-Input-and-Output"></a>
<a name="SEC68"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="maxima_12.html#SEC67" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC69" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima_12.html#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_14.html#SEC74" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_82.html#SEC380" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 13. File Input and Output </h1>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC69">13.1 Comments</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC70">13.2 Files</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC71">13.3 Functions and Variables for File Input and Output</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC72">13.4 Functions and Variables for TeX Output</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC73">13.5 Functions and Variables for Fortran Output</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<p><a name="Item_003a-Comments"></a>
</p><hr size="6">
<a name="Comments"></a>
<a name="SEC69"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC68" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC70" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC68" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC68" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_14.html#SEC74" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_82.html#SEC380" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 13.1 Comments </h2>
<p>A comment in Maxima input is any text between <code>/*</code> and <code>*/</code>.
</p>
<p>The Maxima parser treats a comment as whitespace for the purpose of finding
tokens in the input stream; a token always ends at a comment. An input such as
<code>a/* foo */b</code> contains two tokens, <code>a</code> and <code>b</code>,
and not a single token <code>ab</code>. Comments are otherwise ignored by Maxima;
neither the content nor the location of comments is stored in parsed input
expressions.
</p>
<p>Comments can be nested to arbitrary depth. The <code>/*</code> and <code>*/</code>
delimiters form matching pairs. There must be the same number of <code>/*</code>
as there are <code>*/</code>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) /* aa is a variable of interest */ aa : 1234;
(%o1) 1234
(%i2) /* Value of bb depends on aa */ bb : aa^2;
(%o2) 1522756
(%i3) /* User-defined infix operator */ infix ("b");
(%o3) b
(%i4) /* Parses same as a b c, not abc */ a/* foo */b/* bar */c;
(%o4) a b c
(%i5) /* Comments /* can be nested /* to any depth */ */ */ 1 + xyz;
(%o5) xyz + 1
</pre>
<div class=categorybox>
·
<p>@ref{Category: Syntax}
</div>
</p>
<p><a name="Item_003a-Files"></a>
</p><hr size="6">
<a name="Files"></a>
<a name="SEC70"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC69" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC71" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC68" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC68" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_14.html#SEC74" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_82.html#SEC380" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 13.2 Files </h2>
<p>A file is simply an area on a particular storage device which contains data
or text. Files on the disks are figuratively grouped into "directories".
A directory is just a list of files. Commands which deal with files are:
</p>
<pre class="verbatim"> appendfile batch batchload
closefile file_output_append filename_merge
file_search file_search_maxima file_search_lisp
file_search_demo file_search_usage file_search_tests
file_type file_type_lisp file_type_maxima
load load_pathname loadfile
loadprint pathname_directory pathname_name
pathname_type printfile save
stringout with_stdout writefile
</pre>
<p>When a file name is passed to functions like <code><a href="maxima_12.html#plot2d">plot2d</a></code>,
<code><a href="#save">save</a></code>, or <code><a href="#writefile">writefile</a></code> and the file name does not include a path,
Maxima stores the file in the current working directory. The current working
directory depends on the system like Windows or Linux and on the installation.
</p>
<p><a name="Item_003a-Functions-and-Variables-for-File-Input-and-Output"></a>
</p><hr size="6">
<a name="Functions-and-Variables-for-File-Input-and-Output"></a>
<a name="SEC71"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC70" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC72" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC68" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC68" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_14.html#SEC74" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_82.html#SEC380" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 13.3 Functions and Variables for File Input and Output </h2>
<p><a name="appendfile"></a>
<a name="Item_003a-appendfile"></a>
</p><dl>
<dt><u>Function:</u> <b>appendfile</b><i> (<var>filename</var>)</i>
<a name="IDX573"></a>
</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>
·
<p>@ref{Category: File output} ·
@ref{Category: Console interaction}
</div>
</p></dd></dl>
<p><a name="batch"></a>
<a name="Item_003a-batch"></a>
</p><dl>
<dt><u>Function:</u> <b>batch</b><i> (<var>filename</var>)</i>
<a name="IDX574"></a>
</dt>
<dt><u>Function:</u> <b>batch</b><i> (<var>filename</var>, <code>option</code>)</i>
<a name="IDX575"></a>
</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>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_3.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_4.html#g_t_0025">%</a></code> and the function
<code><a href="maxima_4.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_11.html#asksign">asksign</a></code> or <code><a href="maxima_11.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 argument. <code>batch</code> returns the path of
<var>filename</var> as a string, when called with no second argument or with the
option <code>demo</code>. 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_3.html#demo">demo</a></code>.
</p>
<div class=categorybox>
·
<p>@ref{Category: Session management} ·
@ref{Category: File input}
</div>
</p></dd></dl>
<p><a name="batchload"></a>
<a name="Item_003a-batchload"></a>
</p><dl>
<dt><u>Function:</u> <b>batchload</b><i> (<var>filename</var>)</i>
<a name="IDX576"></a>
</dt>
<dd><p>Reads Maxima expressions from <var>filename</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_4.html#print">print</a></code> or
<code><a href="maxima_3.html#describe">describe</a></code>)) is displayed, however.
</p>
<p>The special variable <code><a href="maxima_4.html#g_t_0025">%</a></code> and the function <code><a href="maxima_4.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> returns the path of <var>filename</var>, as a string.
<code>batchload</code> evaluates its argument.
</p>
<p>See also <code><a href="#batch">batch</a></code>, and <code><a href="#load">load</a></code>.
</p>
<div class=categorybox>
·
<p>@ref{Category: Session management} ·
@ref{Category: File input}
</div>
</p></dd></dl>
<p><a name="closefile"></a>
<a name="Item_003a-closefile"></a>
</p><dl>
<dt><u>Function:</u> <b>closefile</b><i> ()</i>
<a name="IDX577"></a>
</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>
·
<p>@ref{Category: File output} ·
@ref{Category: Console interaction}
</div>
</p></dd></dl>
<p><a name="file_005foutput_005fappend"></a>
<a name="Item_003a-file_005foutput_005fappend"></a>
</p><dl>
<dt><u>Option variable:</u> <b>file_output_append</b>
<a name="IDX578"></a>
</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="#tex">tex</a></code> and
<code><a href="#appendfile">appendfile</a></code> always append.
</p>
<div class=categorybox>
·
<p>@ref{Category: File output} ·
@ref{Category: Global flags}
</div>
</p></dd></dl>
<p><a name="filename_005fmerge"></a>
<a name="Item_003a-filename_005fmerge"></a>
</p><dl>
<dt><u>Function:</u> <b>filename_merge</b><i> (<var>path</var>, <var>filename</var>)</i>
<a name="IDX579"></a>
</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>
·
<p>@ref{Category: File input} ·
@ref{Category: File output}
</div>
</p></dd></dl>
<p><a name="file_005fsearch"></a>
<a name="Item_003a-file_005fsearch"></a>
</p><dl>
<dt><u>Function:</u> <b>file_search</b><i> (<var>filename</var>)</i>
<a name="IDX580"></a>
</dt>
<dt><u>Function:</u> <b>file_search</b><i> (<var>filename</var>, <var>pathlist</var>)</i>
<a name="IDX581"></a>
</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>
<pre class="example">file_search ("/home/wfs/special/zeta.mac");
file_search ("zeta.mac");
file_search ("zeta");
</pre>
<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 a 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>
·
<p>@ref{Category: File input}
</div>
</p></dd></dl>
<p><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-file_005fsearch_005fmaxima"></a>
</p><dl>
<dt><u>Option variable:</u> <b>file_search_maxima</b>
<a name="IDX582"></a>
</dt>
<dt><u>Option variable:</u> <b>file_search_lisp</b>
<a name="IDX583"></a>
</dt>
<dt><u>Option variable:</u> <b>file_search_demo</b>
<a name="IDX584"></a>
</dt>
<dt><u>Option variable:</u> <b>file_search_usage</b>
<a name="IDX585"></a>
</dt>
<dt><u>Option variable:</u> <b>file_search_tests</b>
<a name="IDX586"></a>
</dt>
<dd><p>These variables specify lists of directories to be searched by
<code><a href="#load">load</a></code>, <code><a href="maxima_3.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>
<pre class="example">file_search_maxima: ["/usr/local/foo/###.mac",
"/usr/local/bar/###.mac"]$
</pre>
<p>replaces the default value of <code>file_search_maxima</code>, while
</p>
<pre class="example">file_search_maxima: append (file_search_maxima,
["/usr/local/foo/###.mac", "/usr/local/bar/###.mac"])$
</pre>
<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_32.html#SEC176">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>
<pre class="example">"/home/{wfs,gcj}/###.{lisp,mac}"
</pre>
<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>
·
<p>@ref{Category: File input} ·
@ref{Category: Global variables}
</div>
</p></dd></dl>
<p><a name="file_005ftype"></a>
<a name="Item_003a-file_005ftype"></a>
</p><dl>
<dt><u>Function:</u> <b>file_type</b><i> (<var>filename</var>)</i>
<a name="IDX587"></a>
</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>
<pre class="example">(%i2) map('file_type,
["test.lisp", "test.mac", "test.dem", "test.txt"]);
(%o2) [lisp, maxima, maxima, object]
</pre>
<div class=categorybox>
·
<p>@ref{Category: File input}
</div>
</p></dd></dl>
<p><a name="file_005ftype_005flisp"></a>
<a name="Item_003a-file_005ftype_005flisp"></a>
</p><dl>
<dt><u>Option variable:</u> <b>file_type_lisp</b>
<a name="IDX588"></a>
</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>
<p><a name="file_005ftype_005fmaxima"></a>
<a name="Item_003a-file_005ftype_005fmaxima"></a>
</p><dl>
<dt><u>Option variable:</u> <b>file_type_maxima</b>
<a name="IDX589"></a>
</dt>
<dd><p>Default value: <code>[mac, mc, demo, dem, dm1, dm2, dm3, dmt]</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>
<p><a name="load"></a>
<a name="Item_003a-load"></a>
</p><dl>
<dt><u>Function:</u> <b>load</b><i> (<var>filename</var>)</i>
<a name="IDX590"></a>
</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>. 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_36.html#translate_005ffile">translate_file</a></code>, and <code><a href="maxima_36.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>See also <code><a href="#loadfile">loadfile</a></code>, <code><a href="#batch">batch</a></code>, <code><a href="#batchload">batchload</a></code>, and
<code><a href="maxima_3.html#demo">demo</a></code>. <code>loadfile</code> processes Lisp files; <code>batch</code>,
<code>batchload</code>, and <code>demo</code> process Maxima files.
</p>
<p>See <code><a href="#file_005fsearch">file_search</a></code> for more detail about the file search mechanism.
</p>
<p><code>load</code> evaluates its argument.
</p>
<div class=categorybox>
·
<p>@ref{Category: Session management} ·
@ref{Category: File input}
</div>
</p></dd></dl>
<p><a name="load_005fpathname"></a>
<a name="Item_003a-load_005fpathname"></a>
</p><dl>
<dt><u>System variable:</u> <b>load_pathname</b>
<a name="IDX591"></a>
</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>
<pre class="example">print("The value of load_pathname is: ", load_pathname)$
print("End of batchfile")$
</pre>
<p>then we get the following output
</p>
<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 class=categorybox>
·
<p>@ref{Category: File input}
</div>
</p></dd></dl>
<p><a name="loadfile"></a>
<a name="Item_003a-loadfile"></a>
</p><dl>
<dt><u>Function:</u> <b>loadfile</b><i> (<var>filename</var>)</i>
<a name="IDX592"></a>
</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>,
<code><a href="maxima_36.html#translate_005ffile">translate_file</a></code>, and <code><a href="maxima_36.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>
·
<p>@ref{Category: Session management} ·
@ref{Category: File input}
</div>
</p></dd></dl>
<p><a name="loadprint"></a>
<a name="Item_003a-loadprint"></a>
</p><dl>
<dt><u>Option variable:</u> <b>loadprint</b>
<a name="IDX593"></a>
</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_33.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>
·
<p>@ref{Category: File input} ·
@ref{Category: Global flags}
</div>
</p></dd></dl>
<p><a name="pathname_005fdirectory"></a>
<a name="pathname_005fname"></a>
<a name="pathname_005ftype"></a>
<a name="Item_003a-pathname_005fdirectory"></a>
</p><dl>
<dt><u>Function:</u> <b>pathname_directory</b><i> (<var>pathname</var>)</i>
<a name="IDX594"></a>
</dt>
<dt><u>Function:</u> <b>pathname_name</b><i> (<var>pathname</var>)</i>
<a name="IDX595"></a>
</dt>
<dt><u>Function:</u> <b>pathname_type</b><i> (<var>pathname</var>)</i>
<a name="IDX596"></a>
</dt>
<dd><p>These functions return the components of <var>pathname</var>.
</p>
<p>Examples:
</p>
<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 class=categorybox>
·
<p>@ref{Category: File input}
</div>
</p></dd></dl>
<p><a name="printfile"></a>
<a name="Item_003a-printfile"></a>
</p><dl>
<dt><u>Function:</u> <b>printfile</b><i> (<var>path</var>)</i>
<a name="IDX597"></a>
</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>
·
<p>@ref{Category: File input} ·
@ref{Category: Console interaction}
</div>
</p></dd></dl>
<p><a name="save"></a>
<a name="Item_003a-save"></a>
</p><dl>
<dt><u>Function:</u> <b>save</b><i> (<var>filename</var>, <var>name_1</var>, <var>name_2</var>, <var>name_3</var>, …)</i>
<a name="IDX598"></a>
</dt>
<dt><u>Function:</u> <b>save</b><i> (<var>filename</var>, values, functions, labels, …)</i>
<a name="IDX599"></a>
</dt>
<dt><u>Function:</u> <b>save</b><i> (<var>filename</var>, [<var>m</var>, <var>n</var>])</i>
<a name="IDX600"></a>
</dt>
<dt><u>Function:</u> <b>save</b><i> (<var>filename</var>, <var>name_1</var>=<var>expr_1</var>, …)</i>
<a name="IDX601"></a>
</dt>
<dt><u>Function:</u> <b>save</b><i> (<var>filename</var>, all)</i>
<a name="IDX602"></a>
</dt>
<dt><u>Function:</u> <b>save</b><i> (<var>filename</var>, <var>name_1</var>=<var>expr_1</var>, <var>name_2</var>=<var>expr_2</var>, …)</i>
<a name="IDX603"></a>
</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.
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_4.html#values">values</a></code>, <code><a href="maxima_36.html#functions">functions</a></code>,
<code><a href="maxima_4.html#labels">labels</a></code>, etc. The names may be any specified by the variable
<code><a href="maxima_4.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_4.html#showtime">showtime</a></code>, if they
have been assigned new values by the user; see <code><a href="maxima_4.html#myoptions">myoptions</a></code>.
</p>
<p><code>save</code> evaluates <var>filename</var> and quotes all other arguments.
</p>
<div class=categorybox>
·
<p>@ref{Category: Session management} ·
@ref{Category: File output}
</div>
</p></dd></dl>
<p><a name="stringout"></a>
<a name="Item_003a-stringout"></a>
</p><dl>
<dt><u>Function:</u> <b>stringout</b><i> (<var>filename</var>, <var>expr_1</var>, <var>expr_2</var>, <var>expr_3</var>, …)</i>
<a name="IDX604"></a>
</dt>
<dt><u>Function:</u> <b>stringout</b><i> (<var>filename</var>, [<var>m</var>, <var>n</var>])</i>
<a name="IDX605"></a>
</dt>
<dt><u>Function:</u> <b>stringout</b><i> (<var>filename</var>, input)</i>
<a name="IDX606"></a>
</dt>
<dt><u>Function:</u> <b>stringout</b><i> (<var>filename</var>, functions)</i>
<a name="IDX607"></a>
</dt>
<dt><u>Function:</u> <b>stringout</b><i> (<var>filename</var>, values)</i>
<a name="IDX608"></a>
</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_3.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_4.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_36.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_4.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>
·
<p>@ref{Category: Session management} ·
@ref{Category: File output}
</div>
</p></dd></dl>
<p><a name="with_005fstdout"></a>
<a name="Item_003a-with_005fstdout"></a>
</p><dl>
<dt><u>Function:</u> <b>with_stdout</b><i> (<var>f</var>, <var>expr_1</var>, <var>expr_2</var>, <var>expr_3</var>, …)</i>
<a name="IDX609"></a>
</dt>
<dt><u>Function:</u> <b>with_stdout</b><i> (<var>s</var>, <var>expr_1</var>, <var>expr_2</var>, <var>expr_3</var>, …)</i>
<a name="IDX610"></a>
</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_4.html#print">print</a></code>, <code><a href="maxima_4.html#display">display</a></code>, <code><a href="maxima_4.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>.
</p>
<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 class=categorybox>
·
<p>@ref{Category: File output}
</div>
</p></dd></dl>
<p><a name="writefile"></a>
<a name="Item_003a-writefile"></a>
</p><dl>
<dt><u>Function:</u> <b>writefile</b><i> (<var>filename</var>)</i>
<a name="IDX611"></a>
</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_4.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>
·
<p>@ref{Category: File output} ·
@ref{Category: Console interaction}
</div>
</p></dd></dl>
<p><a name="Item_003a-Functions-and-Variables-for-TeX-Output"></a>
</p><hr size="6">
<a name="Functions-and-Variables-for-TeX-Output"></a>
<a name="SEC72"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC71" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC73" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC68" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC68" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_14.html#SEC74" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_82.html#SEC380" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 13.4 Functions and Variables for TeX Output </h2>
<p><a name="tex"></a>
<a name="Item_003a-tex"></a>
</p><dl>
<dt><u>Function:</u> <b>tex</b><i> (<var>expr</var>)</i>
<a name="IDX612"></a>
</dt>
<dt><u>Function:</u> <b>tex</b><i> (<var>expr</var>, <var>destination</var>)</i>
<a name="IDX613"></a>
</dt>
<dt><u>Function:</u> <b>tex</b><i> (<var>expr</var>, false)</i>
<a name="IDX614"></a>
</dt>
<dt><u>Function:</u> <b>tex</b><i> (<var>label</var>)</i>
<a name="IDX615"></a>
</dt>
<dt><u>Function:</u> <b>tex</b><i> (<var>label</var>, <var>destination</var>)</i>
<a name="IDX616"></a>
</dt>
<dt><u>Function:</u> <b>tex</b><i> (<var>label</var>, false)</i>
<a name="IDX617"></a>
</dt>
<dd><p>Prints a representation of an expression suitable for the TeX document
preparation system. The result is a fragment of a document, which can be copied
into a larger document but not processed by itself.
</p>
<p><code>tex (<var>expr</var>)</code> prints a TeX representation of <var>expr</var> on the
console.
</p>
<p><code>tex (<var>label</var>)</code> prints a TeX representation of the expression named by
<var>label</var> and assigns it an equation label (to be displayed to the left of the
expression). The TeX equation label is the same as the Maxima label.
</p>
<p><var>destination</var> may be an output stream or file name. When <var>destination</var>
is a file name, <code>tex</code> appends its output to the file. The functions
<code>openw</code> and <code>opena</code> create output streams.
</p>
<p><code>tex (<var>expr</var>, false)</code> and <code>tex (<var>label</var>, false)</code>
return their TeX output as a string.
</p>
<p><code>tex</code> evaluates its first argument after testing it to see if it is a
label. Quote-quote <code>''</code> forces evaluation of the argument, thereby
defeating the test and preventing the label.
</p>
<p>See also <code><a href="#texput">texput</a></code>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) integrate (1/(1+x^3), x);
2 x - 1
2 atan(-------)
log(x - x + 1) sqrt(3) log(x + 1)
(%o1) - --------------- + ------------- + ----------
6 sqrt(3) 3
(%i2) tex (%o1);
$$-{{\log \left(x^2-x+1\right)}\over{6}}+{{\arctan \left({{2\,x-1
}\over{\sqrt{3}}}\right)}\over{\sqrt{3}}}+{{\log \left(x+1\right)
}\over{3}}\leqno{\tt (\%o1)}$$
(%o2) (\%o1)
(%i3) tex (integrate (sin(x), x));
$$-\cos x$$
(%o3) false
(%i4) tex (%o1, "foo.tex");
(%o4) (\%o1)
</pre>
<p><code>tex (<var>expr</var>, false)</code> returns its TeX output as a string.
</p>
<pre class="example">(%i1) S : tex (x * y * z, false);
(%o1) $$x\,y\,z$$
(%i2) S;
(%o2) $$x\,y\,z$$
</pre>
<div class=categorybox>
·
<p>@ref{Category: TeX output} ·
@ref{Category: File output}
</div>
</p></dd></dl>
<p><a name="tex1"></a>
<a name="Item_003a-tex1"></a>
</p><dl>
<dt><u>Function:</u> <b>tex1</b><i> (<var>e</var>)</i>
<a name="IDX618"></a>
</dt>
<dd><p>Returns a string which represents the TeX output for the expressions <var>e</var>.
The TeX output is not enclosed in delimiters for an equation or any other
environment.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) tex1 (sin(x) + cos(x));
(%o1) \sin x+\cos x
</pre></dd></dl>
<p><a name="texput"></a>
<a name="Item_003a-texput"></a>
</p><dl>
<dt><u>Function:</u> <b>texput</b><i> (<var>a</var>, <var>s</var>)</i>
<a name="IDX619"></a>
</dt>
<dt><u>Function:</u> <b>texput</b><i> (<var>a</var>, <var>f</var>)</i>
<a name="IDX620"></a>
</dt>
<dt><u>Function:</u> <b>texput</b><i> (<var>a</var>, <var>s</var>, <var>operator_type</var>)</i>
<a name="IDX621"></a>
</dt>
<dt><u>Function:</u> <b>texput</b><i> (<var>a</var>, [<var>s_1</var>, <var>s_2</var>], matchfix)</i>
<a name="IDX622"></a>
</dt>
<dt><u>Function:</u> <b>texput</b><i> (<var>a</var>, [<var>s_1</var>, <var>s_2</var>, <var>s_3</var>], matchfix)</i>
<a name="IDX623"></a>
</dt>
<dd><p>Assign the TeX output for the atom <var>a</var>, which can be a symbol or the name
of an operator.
</p>
<p><code>texput (<var>a</var>, <var>s</var>)</code> causes the <code>tex</code> function to interpolate
the string <var>s</var> into the TeX output in place of <var>a</var>.
</p>
<p><code>texput (<var>a</var>, <var>f</var>)</code> causes the <code>tex</code> function to call the
function <var>f</var> to generate TeX output. <var>f</var> must accept one argument,
which is an expression which has operator <var>a</var>, and must return a string
(the TeX output). <var>f</var> may call <code>tex1</code> to generate TeX output for the
arguments of the input expression.
</p>
<p><code>texput (<var>a</var>, <var>s</var>, <var>operator_type</var>)</code>, where <var>operator_type</var>
is <code>prefix</code>, <code>infix</code>, <code>postfix</code>, <code>nary</code>, or <code>nofix</code>,
causes the <code>tex</code> function to interpolate <var>s</var> into the TeX output in
place of <var>a</var>, and to place the interpolated text in the appropriate
position.
</p>
<p><code>texput (<var>a</var>, [<var>s_1</var>, <var>s_2</var>], matchfix)</code> causes the <code>tex</code>
function to interpolate <var>s_1</var> and <var>s_2</var> into the TeX output on either
side of the arguments of <var>a</var>. The arguments (if more than one) are
separated by commas.
</p>
<p><code>texput (<var>a</var>, [<var>s_1</var>, <var>s_2</var>, <var>s_3</var>], matchfix)</code> causes the
<code>tex</code> function to interpolate <var>s_1</var> and <var>s_2</var> into the TeX output
on either side of the arguments of <var>a</var>, with <var>s_3</var> separating the
arguments.
</p>
<p>Examples:
</p>
<p>Assign TeX output for a variable.
</p>
<pre class="example">(%i1) texput (me,"\\mu_e");
(%o1) \mu_e
(%i2) tex (me);
$$\mu_e$$
(%o2) false
</pre>
<p>Assign TeX output for an ordinary function (not an operator).
</p>
<pre class="example">(%i1) texput (lcm, "\\mathrm{lcm}");
(%o1) \mathrm{lcm}
(%i2) tex (lcm (a, b));
$$\mathrm{lcm}\left(a , b\right)$$
(%o2) false
</pre>
<p>Call a function to generate TeX output.
</p>
<pre class="example">(%i1) texfoo (e) := block ([a, b], [a, b] : args (e),
concat("\\left[\\stackrel{",tex1(b),"}{",tex1(a),"}\\right]"))$
(%i2) texput (foo, texfoo);
(%o2) texfoo
(%i3) tex (foo (2^x, %pi));
$$\left[\stackrel{\pi}{2^{x}}\right]$$
(%o3) false
</pre>
<p>Assign TeX output for a prefix operator.
</p>
<pre class="example">(%i1) prefix ("grad");
(%o1) grad
(%i2) texput ("grad", " \\nabla ", prefix);
(%o2) \nabla
(%i3) tex (grad f);
$$ \nabla f$$
(%o3) false
</pre>
<p>Assign TeX output for an infix operator.
</p>
<pre class="example">(%i1) infix ("~");
(%o1) ~
(%i2) texput ("~", " \\times ", infix);
(%o2) \times
(%i3) tex (a ~ b);
$$a \times b$$
(%o3) false
</pre>
<p>Assign TeX output for a postfix operator.
</p>
<pre class="example">(%i1) postfix ("##");
(%o1) ##
(%i2) texput ("##", "!!", postfix);
(%o2) !!
(%i3) tex (x ##);
$$x!!$$
(%o3) false
</pre>
<p>Assign TeX output for a nary operator.
</p>
<pre class="example">(%i1) nary ("@@");
(%o1) @@
(%i2) texput ("@@", " \\circ ", nary);
(%o2) \circ
(%i3) tex (a @@ b @@ c @@ d);
$$a \circ b \circ c \circ d$$
(%o3) false
</pre>
<p>Assign TeX output for a nofix operator.
</p>
<pre class="example">(%i1) nofix ("foo");
(%o1) foo
(%i2) texput ("foo", "\\mathsc{foo}", nofix);
(%o2) \mathsc{foo}
(%i3) tex (foo);
$$\mathsc{foo}$$
(%o3) false
</pre>
<p>Assign TeX output for a matchfix operator.
</p>
<pre class="example">(%i1) matchfix ("<<", ">>");
(%o1) <<
(%i2) texput ("<<", [" \\langle ", " \\rangle "], matchfix);
(%o2) [ \langle , \rangle ]
(%i3) tex (<<a>>);
$$ \langle a \rangle $$
(%o3) false
(%i4) tex (<<a, b>>);
$$ \langle a , b \rangle $$
(%o4) false
(%i5) texput ("<<", [" \\langle ", " \\rangle ", " \\, | \\,"],
matchfix);
(%o5) [ \langle , \rangle , \, | \,]
(%i6) tex (<<a>>);
$$ \langle a \rangle $$
(%o6) false
(%i7) tex (<<a, b>>);
$$ \langle a \, | \,b \rangle $$
(%o7) false
</pre>
<div class=categorybox>
·
<p>@ref{Category: TeX output}
</div>
</p></dd></dl>
<p><a name="get_005ftex_005fenvironment"></a>
<a name="Item_003a-get_005ftex_005fenvironment"></a>
</p><dl>
<dt><u>Function:</u> <b>get_tex_environment</b><i> (<var>op</var>)</i>
<a name="IDX624"></a>
</dt>
<dt><u>Function:</u> <b>set_tex_environment</b><i> (<var>op</var>, <var>before</var>, <var>after</var>)</i>
<a name="IDX625"></a>
</dt>
<dd><p>Customize the TeX environment output by <code>tex</code>.
As maintained by these functions, the TeX environment comprises two strings:
one is printed before any other TeX output, and the other is printed after.
</p>
<p>Only the TeX environment of the top-level operator in an expression
is output; TeX environments associated with other operators are ignored.
</p>
<p><code>get_tex_environment</code> returns the TeX enviroment which is applied
to the operator <var>op</var>; returns the default if no other environment
has been assigned.
</p>
<p><code>set_tex_environment</code> assigns the TeX environment for the operator
<var>op</var>.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) get_tex_environment (":=");
(%o1) [
\begin{verbatim}
, ;
\end{verbatim}
]
(%i2) tex (f (x) := 1 - x);
\begin{verbatim}
f(x):=1-x;
\end{verbatim}
(%o2) false
(%i3) set_tex_environment (":=", "$$", "$$");
(%o3) [$$, $$]
(%i4) tex (f (x) := 1 - x);
$$f(x):=1-x$$
(%o4) false
</pre>
<div class=categorybox>
·
<p>@ref{Category: TeX output}
</div>
</p></dd></dl>
<p><a name="get_005ftex_005fenviroment_005fdefault"></a>
<a name="Item_003a-get_005ftex_005fenvironment_005fdefault"></a>
</p><dl>
<dt><u>Function:</u> <b>get_tex_environment_default</b><i> ()</i>
<a name="IDX626"></a>
</dt>
<dt><u>Function:</u> <b>set_tex_environment_default</b><i> (<var>before</var>, <var>after</var>)</i>
<a name="IDX627"></a>
</dt>
<dd><p>Customize the TeX environment output by <code>tex</code>.
As maintained by these functions, the TeX environment comprises two strings:
one is printed before any other TeX output, and the other is printed after.
</p>
<p><code>get_tex_environment_default</code> returns the TeX environment which is
applied to expressions for which the top-level operator has no
specific TeX environment (as assigned by <code>set_tex_environment</code>).
</p>
<p><code>set_tex_environment_default</code> assigns the default TeX environment.
</p>
<p>Examples:
</p>
<pre class="example">(%i1) get_tex_environment_default ();
(%o1) [$$, $$]
(%i2) tex (f(x) + g(x));
$$g\left(x\right)+f\left(x\right)$$
(%o2) false
(%i3) set_tex_environment_default ("\\begin{equation}
", "
\\end{equation}");
(%o3) [\begin{equation}
,
\end{equation}]
(%i4) tex (f(x) + g(x));
\begin{equation}
g\left(x\right)+f\left(x\right)
\end{equation}
(%o4) false
</pre>
<div class=categorybox>
·
<p>@ref{Category: TeX output}
</div>
</p></dd></dl>
<p><a name="Item_003a-Functions-and-Variables-for-Fortran-Output"></a>
</p><hr size="6">
<a name="Functions-and-Variables-for-Fortran-Output"></a>
<a name="SEC73"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC72" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="maxima_14.html#SEC74" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC68" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC68" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_14.html#SEC74" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_82.html#SEC380" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 13.5 Functions and Variables for Fortran Output </h2>
<p><a name="fortindent"></a>
<a name="Item_003a-fortindent"></a>
</p><dl>
<dt><u>Option variable:</u> <b>fortindent</b>
<a name="IDX628"></a>
</dt>
<dd><p>Default value: <code>0</code>
</p>
<p><code>fortindent</code> controls the left margin indentation of
expressions printed out by the <code><a href="#fortran">fortran</a></code> command. <code>0</code> gives normal
printout (i.e., 6 spaces), and positive values will causes the
expressions to be printed farther to the right.
</p>
<div class=categorybox>
·
<p>@ref{Category: Translation and compilation}
</div>
</p></dd></dl>
<p><a name="fortran"></a>
<a name="Item_003a-fortran"></a>
</p><dl>
<dt><u>Function:</u> <b>fortran</b><i> (<var>expr</var>)</i>
<a name="IDX629"></a>
</dt>
<dd><p>Prints <var>expr</var> as a Fortran statement.
The output line is indented with spaces.
If the line is too long, <code>fortran</code> prints continuation lines.
<code>fortran</code> prints the exponentiation operator <code>^</code> as <code>**</code>,
and prints a complex number <code>a + b %i</code> in the form <code>(a,b)</code>.
</p>
<p><var>expr</var> may be an equation. If so, <code>fortran</code> prints an assignment
statement, assigning the right-hand side of the equation to the left-hand side.
In particular, if the right-hand side of <var>expr</var> is the name of a matrix,
then <code>fortran</code> prints an assignment statement for each element of the
matrix.
</p>
<p>If <var>expr</var> is not something recognized by <code>fortran</code>,
the expression is printed in <code><a href="maxima_4.html#grind">grind</a></code> format without complaint.
<code>fortran</code> does not know about lists, arrays, or functions.
</p>
<p><code><a href="#fortindent">fortindent</a></code> controls the left margin of the printed lines.
<code>0</code> is the normal margin (i.e., indented 6 spaces). Increasing
<code>fortindent</code> causes expressions to be printed further to the right.
</p>
<p>When <code><a href="#fortspaces">fortspaces</a></code> is <code>true</code>, <code>fortran</code> fills out
each printed line with spaces to 80 columns.
</p>
<p><code>fortran</code> evaluates its arguments; quoting an argument defeats evaluation.
<code>fortran</code> always returns <code>done</code>.
</p>
<p>See also the function <code><a href="maxima_52.html#function_005ff90">f90</a></code> for printing one or more
expressions as a Fortran 90 program.
</p>
<p>Examples:
</p>
<pre class="verbatim">(%i1) expr: (a + b)^12$
(%i2) fortran (expr);
(b+a)**12
(%o2) done
(%i3) fortran ('x=expr);
x = (b+a)**12
(%o3) done
(%i4) fortran ('x=expand (expr));
x = b**12+12*a*b**11+66*a**2*b**10+220*a**3*b**9+495*a**4*b**8+792
1 *a**5*b**7+924*a**6*b**6+792*a**7*b**5+495*a**8*b**4+220*a**9*b
2 **3+66*a**10*b**2+12*a**11*b+a**12
(%o4) done
(%i5) fortran ('x=7+5*%i);
x = (7,5)
(%o5) done
(%i6) fortran ('x=[1,2,3,4]);
x = [1,2,3,4]
(%o6) done
(%i7) f(x) := x^2$
(%i8) fortran (f);
f
(%o8) done
</pre>
<div class=categorybox>
·
<p>@ref{Category: Translation and compilation}
</div>
</p></dd></dl>
<p><a name="fortspaces"></a>
<a name="Item_003a-fortspaces"></a>
</p><dl>
<dt><u>Option variable:</u> <b>fortspaces</b>
<a name="IDX630"></a>
</dt>
<dd><p>Default value: <code>false</code>
</p>
<p>When <code>fortspaces</code> is <code>true</code>, <code>fortran</code> fills out
each printed line with spaces to 80 columns.
</p>
<div class=categorybox>
·
<p>@ref{Category: Translation and compilation}
</div>
</p></dd></dl>
<p><a name="Item_003a-Polynomials"></a>
</p><hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC68" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="maxima_14.html#SEC74" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_82.html#SEC380" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>root</em> on <em>January, 10 2014</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
</font>
<br>
</p>
</body>
</html>
|