Personal tools
You are here: Home / cmgui / Wiki / Using Cmiss Perl
Navigation
Log in


Forgot your password?
 

Using Cmiss Perl

<ul><li> <b>Output.</b> If you want all your commands echoed when they actually happen then you can get the interpreter (itp environment) to do this for you. <br>'itp set echo on' <br>By default the echoed commands are written verbatim. You can choose to

add a string to the start of every echoed line using.....

<br>'itp set echo prompt :)' </li><li> <b>Debug.</b> If you really want to see the lexical analysis of the Perl interpreter then you can get the interpreter to write this out. <br>'itp set debug on' </li><li> <b>Comfiles.</b>If you are reading a comfile containing a mixture of Perl and Cmiss commands then you must continue to read it in with read com;FILENAME or open comfile FILENAME exec so that the cmiss commands get mangled into Perl. If your script is pure perl then you can use require, do or use as normal. </li><li> Each space separated expression is assumed to be a single token for cmiss. <br>i.e. gfx cre win "bob is a fish" creates a window called "bob is a fish" this means that <br> $fred = "win bob" <br> gfx cre $fred <br>does not create a window called bob. To do something like this see the next section. </li><li><b>The cmiss command.</b> The Perl interpreter works by declaring a function Perl_cmiss::cmiss or just cmiss, that is a valid Perl function. If for some reason the Perl interpreter won't interpret your cmiss command the way you think it should then you can pass this function a string and that string will go directly to cmiss. <br>i.e. $bob = "win 10"; cmiss("gfx cre $bob"); </li><li><b>The gfx * separator.</b> As an asterisk now denotes multiplication the

use of asterisks to separate directions in element and glyph sizes must now be quoted.
<br>gfx mod g_e heart element_points size 2*1*0.4 is actually the same as
gfx mod g_e heart element_points size 0.8

<br>so instead quote the terms, gfx mod g_e heart element_points size "2*1*0.4" </li><li><b>Comments.</b> The comment character is now a #. </li><li><b>open.</b> As open is a valid function in Perl and a starting keyword in

CMISS you currently need to escape the CMISS to use the Perl one. You could enclose it in ()'s or explicitly use its module name CORE::open.
</li><li><b>Listing variables.</b> You can list all your defined variables by
looking at the hash of your package. The hash is called cmiss::.

<br>print map { "$_n" } keys %cmiss::; <br>A more user friendly command for this may be put directly into cmiss.

There are some routines for simplifying this in the module CMISS::Utils found in CMISS_ROOT/perl_lib, in particular pscalar, parray and phash.
</li><li><b>ENV environment.</b> If you want to reference something in your
environment then you can just use the automatic Perl Hash ENV. So to reference the environment variable HOST use $ENV{HOST}.

<br>i.e. print "Host from ENV is $ENV{HOST}n"; </li><li><b>itp assert blocks closed.</b> The interpreter suspends execution of

commands until all control structures are complete, i.e. until the closing bracket of all if, for and while statements is reached. Sometimes you may be trapped inside some control loop, nothing will execute and you are unsure how deep you are. You can either keep typing } brackets to try and escape any control statements you are in or you can use the interpreter command, 'itp assert blocks closed'. This command will generate an error if you are in any level of control structure at that time, it will also reset the interpreter, immediately terminating any control structures that may be started without executing them.
</li><li><b>Command line arguments.</b> Cmiss commands can be passed directly to the
interpreter through command line arguments. These are executed first, before any startup comfiles or command line comfiles. This is useful for simple operations such as defining variables used by a comfile. Valid Perl can be separated by semicolons to form multiple statements.

<br>i.e. cm -exec '$FRED="fredstring"; $BOB="bobstring"' </li></ul>