Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to use $include for file inclusion?

138 views
Skip to first unread message

Rainer Rosenthal

unread,
Nov 20, 2009, 4:52:18 PM11/20/09
to
Could you please give me a tiny example for how to
write a little example.mws File which includes
some text file some.txt?

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

Archimedes

unread,
Nov 20, 2009, 5:12:41 PM11/20/09
to

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

Rainer Rosenthal

unread,
Nov 20, 2009, 6:11:25 PM11/20/09
to
Archimedes schrieb:

>
> 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.
>

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

Nasser M. Abbasi

unread,
Nov 20, 2009, 6:14:49 PM11/20/09
to

"Archimedes" <gkok...@yahoo.com> wrote in message
news:b148e755-a6e0-4a17-9cd2-

"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


Archimedes

unread,
Nov 20, 2009, 7:09:09 PM11/20/09
to
On Nov 20, 6:14 pm, "Nasser M. Abbasi" <n...@12000.org> wrote:
> "Archimedes" <gkoko...@yahoo.com> wrote in message

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

acer

unread,
Nov 22, 2009, 10:09:54 AM11/22/09
to


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.

Rainer Rosenthal

unread,
Nov 22, 2009, 10:25:30 AM11/22/09
to
acer wrote:

> 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

Archimedes

unread,
Nov 22, 2009, 3:37:54 PM11/22/09
to

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


Rainer Rosenthal

unread,
Nov 22, 2009, 4:10:07 PM11/22/09
to
Archimedes schrieb:

Thank you very much. That's exactly what I was looking for.
I am an example-driven human being.

Best regards,
Rainer

0 new messages