Command Syntax

The syntax of DPUSER is similar to the C programming language. DPUSER supports a set of types (integers, real numbers, complex numbers, matrices, strings, and string arrays). You can use operators (^, *, /, +, -) to modify values. Functions and Procedures are available, as well as procedural commands like loops and conditional statements. For powerful plotting capabilities, the complete PGPLOT library (including 3D extensions) is available in DPUSER.
Have a look at some examples to see how DPUSER is used.

Scripts

If you wish to save your work, two methods are used. Firstly, DPUSER writes a file history.dpuser when exiting in the current working directory. This file is read in when DPUSER is started again in this directory. Secondly, DPUSER is able to execute scripts. Those use exactly the same syntax as the interactive prompt. You just have to create a plain text input file. Execution of this file is then accomplished using the following syntax:

@script.dpuser
Which is equivalent to:
run "script.dpuser"
Wp> will execute every command in the text file "script.dpuser". Control is returned to the user when the script is finished.

User defined procedures

It is possible to write user defined procedures and store them in local memory. Arguments given to the procedure can be changed. Note, however, that all locally defined variables inside the procedure are local and are not preserved when exiting from the procedure. Also, variables defined outside the procedure are not accessible from within the procedure.
The syntax for defining a procedure is as follows:

procedure NAME, ARG1, ARG2, ... {
  BODY
}

The number of arguments can be anything from 0 to Infinity. To give an example:

procedure test, a, b, c {
  print a
  print b
  c = a + b
}

It this procedure is called like this: a=0;test 1,2,a, the values 1 and 2 will be printed to the screen, and a will have a value of 3. Note that the variables a, b, c inside the procedure are not visible to the outside program.

User defined functions

Functions are similar to procedures (what concerns local variables and passing their values), but they in addition return a value. The syntax for a user written function is:

function NAME, ARG1, ARG2, ... {
  BODY
  NAME = value
}


The return value of the function thus is assigned by creating a variable with the function's name inside the function and assign the return value to it (This is similar to Fortran77). To give an example:

function sqr, a {
  sqr = a * a
}


This function then can be used as any other function, nesting also is allowed:

print sqr(sqr(3)+2)/sqr(4) prints out 7.5625.

External commands

DPUSER provides two methods of executing external commands. The procedure exec allows to execute a command giving a string, which is useful if you like to build the command non-ineractively (eg. in a script). Alternatively, any command can be executed using the following syntax:

!ls -l /tmp (UNIX)
!dir \tmp (WINDOWS)
for example will print out a long listing of the /tmp directory.

Interaction with other programs

If you start up a program like saoimage or ds9, you are able to use the DPUSER commands sao and others, which use the common display library to display and evaluate images (similar to IRAF).

Comments

If you wish to add comments to your scripts (or at the interactive prompt), you can use exactly the same syntax as the C++ programming language. All characters after a // until the end of a line will be regarded as a comment, as is everything embraced by /* ... */:

print "a comment"   // prints out the string "a comment"
print "a longer comment"
/* nothing
   ....
   will be done here
*/
print "but here again"