I am looking for a tutorial or an example how to use Tcl (for example, Tcl /Tk 8.3.1) for Windows in order to provide a web access to my own procedures written in Maple, e.g., to my package CLIFFORD, and then output results back to the web page.
At this point, however, as an example, I would like to write a web page with an appropriate Tcl code that would use my procedure which takes as input two positive integers n1 and n2 and outputs a list of length n1 of positive integers whose sum equals n2. I have written a procedure in Maple V 5.1 that does that; now I would like to make it possible to run it from the web.
Does it have to be Tcl? I could give you access to some perl code that I use. Very brieﬂy, the basic technique that I use, and it would probably need to be similar whatever the CGI processor, is this. Take the form input and write it to a ﬁle in Maple syntax. Include code to load any Maple libraries etc. Start a command-line version of Maple, using the ”system” function or equivalent, that reads the input ﬁle and writes to an output ﬁle.
(You could use pipes instead of intermediate ﬁles, but that is harder to debug and less portable.) Generate appropriate http headers etc, convert the Maple output to whatever format you want to send the user (HTML, MathML, TeX, ...) and output it to the standard output of the CGI program.
There are several perl facilities for generating dynamic HTML, among which I currently use the CGI.pm module. I expect that there are Tcl analogues.
I’ve no knowledge of Tcl, but I’ve had a similar problem with interactions between SAS and Maple. I used the command line interface of Maple, because I could execute dos commands from within SAS.
I used simple .txt-ﬁles to transfer data from SAS to Maple, which can be read in to Maple via the READ statement. I made an .txt-ﬁle containg all Maple statements, and executed a dos-command like c:\maplev\bin.win\cmaple.exe c:\maplefile.txt from within SAS. In the end of the maple-program, i had some WRITEDATA statements, that put the results into txt-ﬁles, and I could then ﬁnally read these from SAS.
I know it’s a long way to go, but I found no better solutions.
I have a related question: I’ve seen how to use perl to fork processes under unix so that perl can load & execute maple code when a web surfer requests. I’m curious however, whether it’s possible with perl to fork a process just once, and then use the same process everytime a webber surfs in?
I think the answer is yes, but I haven’t yet found the need to worry about this so I have no actual experience of it. I believe that apache provides a facility for locking a perl and/or any CGI program in memory. Also, I suggest you take a look at http://www.ActiveState.com/