Sumerian Tablet

The Multiscript Project Page


Multiscript programming allows for multiple scripts to be put inside of a script file. Multiscript consists of a extensible program that then runs the multilingual scripts. It allows for the script files to contain more than one language by using tags to dilineate where the program code starts and ends.

At command line execution a Multiscript program loads the script file and code tags. Second, the Multiscript processes the command line arguments. Third, Multiscript creates a temporary file to store the script code in between code tags. Fourth, the Multiscript program then parses the file and looks for tagged code blocks according to the command line options. The Multiscript program will then execute all of the code blocks, some of the code blocks or none of them.

If a particular argument option is selected it will then store the code in the temporary file at the starting "<code>" tag and execute the file at the end of tag "</code>" code. Multiscript uses a randomized read only temporary file as a buffer to store execution script code. At the end code tag the temporary file is executed by the appropriate language (defined by a tag attributes) and then the temp file is truncated for the next code block. At the end of multiscript file the temporary file is also removed since there is no more code to process and the program terminates.

KEY BENEFITS


Multiscript code is written and executed from Perl or Flex or XML SAX.
Each Multiscript program is extensible and allows multiple languages in a script.
Different languages have different strengths and Multiscript can allow different languages to be used.
Programming can use the strengths of many different languages. Programmers can use Multiscript CGI Web programming.
Multiscript code tags can have attributes to define multiscript program code attributes and define how to execute them.
Multiscripts can be executed by the commandline program located on sourceforge.net.
Alternativelly, there is multiscript Perl CPAN module at CPAN Multiscript Module.
A Multiscript can be loaded from a Perl file by the CGI::Multiscript module to execute external Multiscript files.

EXAMPLE SCRIPT CODE

test.multiscript is an example file is listed as follows. It contains three code groups for helloworld. One code group is Perl, Python and ruby. Different code groups can be added to allow other languages in the same script. Command arguments can also be assigned to the scripts as well as version numbers.

<code>
#!/usr/local/perl
print "hello World\n";
</code>

<code python>
#!/usr/local/python
print "Hello World"
</code python>

<code ruby>
#!/usr/local/python
puts "Hello World"
</code ruby>

The following example code for test_args.multiscript illustrates attributes and arguments that can be used to define code arguments and the language by the l and args attribute.

<code l="perl" args="1 2 3 4 5 6">
#!/usr/local/perl
$numargs = $#ARGV + 1;
print "There are $numargs args\n";
</code>

The following code illustrates Unix shell code for helloworld

<code l="csh">
#!/usr/local/csh
echo "There are Hello World Shell\n";
</code>


CPAN CGI::Multiscript

On CPAN there is a Perl modulule CGI::Multiscript for Multiscript files. This module can be imported into a Perl script and parse and execute Multiscript files.


This is an example of the Perl code that calls the multiscript file.

use CGI::Multiscript;

CGI::Multiscript::setDefault("./");
CGI::Multiscript::setDefault("sh ");
print "Default execution ", CGI::Multiscript::getDefault(), "\n";

$ms = CGI::Multiscript::new("test_hello.ms");
$ms->setFilename("t/test_hello.ms");
$ms->addLanguage('Perl');
print "Current filename ", $ms->getFilename(), "\n";

$ms->execute();

EXAMPLE COMMAND EXECUTION

This is a unix example of running the flex command line program.
[home/user/adam]$ ms -version
Multiscript version 1.0
[home/user/adam]$ ms -file test.ms
Hello World [perl]
[home/user/adam]$ ms -f test.ms -python
Hello World [perl]
Hello World [python]
[home/user/adam]$ ms -f test.ms -python -ruby
Hello World [perl]
Hello World [python]
Hello World [ruby]
[home/user/adam]$ ms -f test_args.ms
There are 6 args
[home/user/adam]$ ms -f test_version.ms -pv 1.2b
This is program version 1.2b
[home/user/adam]$ ms -f webtest.cgi2.ms
<html>
<h1>This is heading 1</h1>
<P>Light
</P>
<P>
The time is February 25 2006
</code>
</p>
</html>

This button will run Multiscript script multiscript.ms.cgi

TO DO LIST

(0) Use An XML SAX parser.
(1) Improve the tag parser.
(2) Add more command line options.
(3) Add more example scripts.


CURRENT VERSION

The current Multiscript flex command line version is .50.

The current CGI::Multiscript Perl module version is .74.


LICENSE

This code has been released under the GPL and Artistic License.


AUTHOR

Nathan Ross © 2006

Last updated on February 27, 2005

SourceForge.net Logo