CmUtils

Some basic utility functions for the CMISS Perl interpreter. Includes functions for directories, creating lists, and printing defined variables.

VERSION

1.10 (7 September 2001)

CHANGES

1.10

GBS:

Added max, min and constrain as utility routines.

Added choose routine to prompt the user to choose between several options. Enabled this routine and ask to use Gtk if running under cmgui.

1.09
Added pushdir and popdir routines for keeping track of directory changes.
1.08

Added functionality when external modules (Data::Dumper etc) are not available.

Test for valid variables in pdefined commands is now on the definition, rather than whether a variable is true or not.

1.07

Changed package name from "CMISS::Utils" to "CmUtils"

Moved help routines back to this module.

1.06
Added "pother" to print other refs (usually objects)
1.05
Moved "h" and "man" routines to the Exporter module.
1.04

Changed to use "CmUtils::Exporter" as the ISA - gives automatic definition of subroutines and help routines

Added "man" function for help on Perl modules

SUBROUTINES

max(list)

Returns the maximum of a list of numbers.

min(list)

Returns the minimum of a list of numbers.

constrain(value, minimum, maximum)

Constrains a numeric variable to lie between two other values. Ensures min < max.

h([name][,topic])

Searches for, and prints, documentation for the NAMEd subroutine/module/object from the CMISS perl modules.

"name" can be either a subroutine name (e.g. 'pdefined'), a module name (e.g. 'CmUtils::Utils') or an object (e.g. $nodegroup).

Additional help available is listed, and can be accessed by specifying a topic along with the name e.g.

  h 'CmUtils::Objects::NodeGroup';
  h 'CmUtils::Objects::NodeGroup','list';

man(name)

Prints the full manpage for the NAMEd module.

ask(question, [default])

Prompts for user-input with QUESTION. Returns the entered string, or DEFAULT if nothing is entered. Now uses Gtk if running cmgui, otherwise prompts in the terminal window.

choose(question, default, choices)

Prompts for user to choose between several options. CHOICES is an array of options, with DEFAULT being the default option in that array (first is zero). Uses Gtk if running cmgui, otherwise prompts in terminal window.

createwin(name)

Creates a NAMEd 3d window in Cmgui, default is window 1. Useful in com files as it doesn't return an warning (and die) if the window already exists.

getcurrentpath()

Returns the current directory path (no trailing slash).

getcurrentdir()

Returns the name of the current directory.

pushdir(dirname)

Stores current directory and changes current directory to DIRNAME.

popdir()

Changes to the previous directory.

cd(dirname)

Changes current directory to DIRNAME for both perl and CMISS. Cmgui handles this alright already.

step(start,end,step)

Returns a list of numbers from START to END in increments of STEP (default 1).

  foreach $value (step(4,20,4)) {  # 4,8,12,16,20

range(start,end,number)

Returns a list of NUMBER values evenly spaced between START and END.

  foreach $value (range(4,20,3)) {  # 4,12,20

proutine(name)

Prints a list of NAMEd or all defined subroutines, along with their stored help-text if available. Specify name as a string.

phash(name)

Prints a list of NAMEd or all defined hashes and hashrefs and their values. Specify name as a string.

parray(name)

Prints a list of NAMEd or all defined arrays and arrayrefs and their values. Specify name as a string.

pscalar(name)

Prints a list of NAMEd or all defined scalars and their values, expect those which are references. Specify name as a string.

pother(name)

Prints a list of NAMEd or all variables other than those printed above. Specify name as a string.

pdefined(name)

Prints a list of NAMEd or all defined variables and subroutines and their values. Specify name as a string.

  pdefined('INC');

penv(name)

Prints a list of NAMEd or all defined environment variables.