As I understand the help pages, all I need to do is just
to write
$include "some.txt"
but it doesn't work for me.
Thank you,
Rainer
From the help file:
IMPORTANT: The preprocessor works only on files being read from the
standard input stream (that is, input redirected into the Command-line
version of Maple by the "<" or "|" facilities provided by UNIX and
Windows shells). The preprocessor is not available in graphical
interface versions of Maple, nor is it available when input is entered
in the Maple command line. To achieve the effect of $define in an
interactive session or Maple worksheet, use the in-lining facility
instead.
If you want a file with a .mw or .mws extension, then you have to use
the "read" command to load the contents of your some.txt file.
Regards,
Georgios
Thank you for your answer. Let me explain what I am looking for.
In my Maple program example.mws there is a table
MyTable := [1,7,19,133,5,18];
From the analogy to the C-preprocessor (see help pages) I concluded
that it should be possible to just put the line
$include "table.txt"
in my program and be happy.
Best regards,
Rainer
"IMPORTANT: The preprocessor works only on files being read from the
standard input stream (that is, input redirected into the Command-line
version of Maple by the "<" or "|" facilities provided by UNIX and
Windows shells)."
Archimedes: I run some maple commands from the DOS commands file just like
this below, and it works
cmaple.exe file.txt
where file.txt is a plain text file with maple commands. The output goes to
the DOS screen.
ie. did not need to use "<" .
--Nasser
Correct, but that is not what the original problem statement was
referring to. It has to do with the preprocessor $include statement,
and that can only be used from cmaple.exe, and not from the GUI
version.
Regards,
Georgios
The functionality changed in Maple 13. The $include directive now
works in a text file (of Maple language commands) that itself is read
from the Standard graphical user interface. See here,
http://www.maplesoft.com/support/help/AddOns/view.aspx?path=updates/Maple13/language
I suspect that the OP could use it within a text file to which the
`read` command is applied from the Standard GUI. Eg. Place multiple
$include directives inside foo.txt, and then read("foo.txt"). That
should even allow for more deeply nested inclusion.
Of course, the include path would have to be correct. See the help-
page for more details on kernelopts(includepath), since if using the
Standard GUI's desktop launcher it is awkward to provide the -I
switch.
> I suspect that the OP could use it within a text file to which the
> `read` command is applied from the Standard GUI. Eg. Place multiple
> $include directives inside foo.txt, and then read("foo.txt"). That
> should even allow for more deeply nested inclusion.
Could you, please, provide a tiny example? As I wrote, it would be nice
if I was able to replace
MyTable := [1,7,19,133,5,18];
by
$include "table.txt"
where the text file table.txt contains the single line
MyTable := [1,7,19,133,5,18];
Thank you.
Rainer
I haven't been able to make it work w/ Maple12 or lower. I do not
have Maple13 @ home to try what Acer suggested above., but it works
with the read command.
I created a file called table.txt in my C:\temp\Maple directory and
the contents of the file are:
MyTable := [1,7,19,133,5,18];
My Maple worksheet looks like this:
restart:
read "c:/temp/Maple/table.txt":
MyTable;
When I execute the commands above, I get the following output:
[1, 7, 19, 133, 5, 18]
Regards,
Georgios
Thank you very much. That's exactly what I was looking for.
I am an example-driven human being.
Best regards,
Rainer