Prev Next Title Contents

VARIABLES


Variables can be used in Gifa, this feature is mainly useful when writing macro commands, however, it can be used at any time in the program. Variable are set (and created if not yet defined) with the command : SET :

Gifa> set b = 'hello world' set c = 3

Gifa> set d := 'hello mom' ; other syntax, see below

Variables are then just used by prefixing the name with a $ :

Gifa> em $c print $b

Variables can be used anywhere a regular entry is needed. Variables are not typed, but contain always a string. The maximum string is currently of 256 characters. The string is interpreted as a number when needed. Variable names are not case sensitive, the name is a maximum of 31 characters long; and must be built from purely alpha-numeric characters only (including the underscore : _ ). The number of available variables is limited at compile time (and reported by the command CONFIG, and variable $VAR_MAX (see below)), but a larger table can easily be built by recompilation if needed.

Associative arrays can be built using the construction [index] :

Gifa> set d[$k] = (cos($k/10))

Associative arrays means that each entry is created when needed, entries do not have to be sequential, and the index does not even have to be integer :

$d[1] ; $d[3] ; $d[$z] ; $d['foo bar']

is a valid array. Associative arrays are coming from the standard UNIX program awk, search for a manual of this program if you some help with associative arrays. The FOREACH control permits to go through all the entries of a given array (see below). The function nextlm() can do the same with a much finer control.

Variables are allocated the first time they are set; referencing a variable not yet allocated generate an error. Variable are automatically deallocated when exiting the macro; they cannot be accessed by any other macros that would be executed during the life of the variable. In other words, variables have local scope, and are volatile (dynamically allocated and removed) (be careful, variables before v4.0 had always global scope !).

Variables created at interactive level (not within a macro) have a special treatment : their life will be as long as the program (unless an UNSET command is explicitly used), and they can be accessed by any other macro : they are static and have global scope.

If you which to create such a static variable from a macro (useful to remember parameters from one call to the other), you can use the following syntax :

set d := 'this variable is static'

If d was already declared as volatile previously in the macro, the preceding command has the effect of creating a new variable, called d, but in the static storage, independent of the volatile d.

SET, UNSET, MUNSET, DUMP

The commands associated to variable handling are :

SET varname = value ; set (and create if needed) the variable

SET var2 = value ; create and set a global variable

UNSET varname ; remove the variable from the table

MUNSET list of vars finishing with a *

; removes all the variables in the list.

DUMP ; dump the content of all currently defined

; variables

The format of the DUMP is : name of the variable ; context of the variable : (20 is static, 21 to 29 are macro call levels) ; content of the variable.

Using DUMP you will find that there might be entries in the variable table that do not correspond to user variables. This is due to the fact that the parser uses this table for particular use (dbm arrays, positions of label, location of WHILE, FOR and FOREACH controls). This entries have different formats from the user variables, thus cannot be mistaken with them. Some of these entries holds binary data that might disturb the terminal when using the DUMP command.

Internal variables

There are also special variables, not defined in the variable table, which takes the value of the internal parameters (contexts) of the Gifa program. These variables can be used, but should never be SET, they should be changed by using the associated commands. The list is currently :

$_
value of the next parameter present on the calling line. CANNOT BE USED WITHIN EVALUATED EXPRESSIONS.
if the following command is used :

@test 3 test.001

within the file test, $_ will be 3 the first time and test.001 the second time.

If no value is present on the calling line, the user will be prompted for the value

$ABSMAX
current value of ABSMAX
$ARG
True (1) if arguments are present on the calling line (within macro only)
$BUTTON
1,2 or 3 depending on which mouse button was last clicked
$CALIBDI[1]
the current calibrating distance, as defined with the CALIBDI command
$CALIBDI[2]
the current calibrating relaxation rate, as defined with the CALIBDI command
$CCOLOR
current value for CCOLOR
$CDISP2D
current value of command CDISP2D
$CHI2
value of the chi2 returned by the last command : MAXENT, LINEFIT, RT->PK
$COL
index of the last extracted column in 2D
$COLOR
current value for COLOR
$CONFIG_GRAPH
is true if graphic is possible (X_window is connected)
$CONFIG_OS
The system type, as returned by the CONFIG command
$CONFIG_PLOT
The plot driver, as returned by the CONFIG command
$CONFIG_WIN
The window manager, as returned by the CONFIG command
$CX
current value for CX
$CY
current value for CY
$CZ
current value for CZ
$C_ABSMAX
value of ABSMAX of the currently JOINed dataset
$C_DIM
value of DIM of the currently JOINed dataset
$C_FREQ
value of FREQ of the currently JOINed dataset
$C_FREQ1
value of FREQ_1D of the currently JOINed dataset
$C_FREQ2
value of FREQ_2D of the currently JOINed dataset
$C_FREQ3
value of FREQ_3D of the currently JOINed dataset
$C_HEADER
last value accessed with the GETHEADER command
$C_JOINED
is if there is a currently JOINed dataset, 0 otherwise
$C_OFFSF1
value of OFFSET_1 of the currently JOINed dataset
$C_OFFSF2
value of OFFSET_2 of the currently JOINed dataset
$C_OFFSF3
value of OFFSET_3 of the currently JOINed dataset
$C_SIZEF1
value of SI1 of the currently JOINed dataset
$C_SIZEF2
value of SI2 of the currently JOINed dataset
$C_SIZEF3
value of SI3 of the currently JOINed dataset
$C_SPECWF1
value of SPECW_1 of the currently JOINed dataset
$C_SPECWF2
value of SPECW_2 of the currently JOINed dataset
$C_SPECWF3
value of SPECW_3 of the currently JOINed dataset
$C_TYPE
value of ITYPE of the currently JOINed dataset
$DIM
current value of DIM
$DISP1D
current value of command DISP1D
$DISP2D
current value of command DISP2D
$DISP3D
current value of command DISP3D
$DIST
the result of the last DIST command
$FND_PK
gives the index of the found entry (FIND)
$FND_PK_DST
gives the distance to target of the found entry (FIND)
$FREQ
main frequency (1H) of the spectrometer
$FREQ_1D
frequency in 1D (in MHz)
$FREQ_1_2D
frequency in 2D in F1 (in MHz)
$FREQ_1_3D
frequency in 3D in F1 (in MHz)
$FREQ_2_2D
frequency in 2D in F2 (in MHz)
$FREQ_2_3D
frequency in 3D in F2 (in MHz)
$FREQ_3_3D
frequency in 3D in F3 (in MHz)
$GB1
value of gb in F1 (in Hz)
$GB2
value of gb in F2 (in Hz)
$GB3
value of gb in F3 (in Hz)
$GIFAPATH
current PATH used for macro, set by th SETPATH command
$HOME
equivalent to the $HOME variable in UNIX
$ITYPE_1D
value of itype in 1D
$ITYPE_2D
value of itype in 2D
$ITYPE_3D
value of itype in 1D
$LB1
value of lb in F1 (in Hz)
$LB2
value of lb in F2 (in Hz)
$LB3
value of lb in F3 (in Hz)
$LEVEL
current value of command LEVEL
$LICENCE
The licence as returned by the CONFIG command
$LOGA
current value of command LOGA
$MAX[1]
value of last computed max computed with the command MAX
$MAX[2]
value of last computed min computed with the command MAX
$MEM_MAX
The larger data set available, as returned by the CONFIG command
$MEM_PRO_1D
The size of the protected 1D area, as returned by the CONFIG command
$MEM_PRO_2D
The size of the protected 2D area, as returned by the CONFIG command
$MEM_PRO_3D
The size of the protected 3D area, as returned by the CONFIG command
$NAME
name of the current data-set
$NAR
number of A.R. coefficients as listed by ARLIST
$NOISE
value of the noise, as given by the NOISE command
$NPK1D
The number of entries in the 1D peak table
$NPK2D
The number of entries in the 2D peak table
$NPK3D
The number of entries in the 3D peak table
$NPOINT
The number of entries in the point stack
$NRT
Number of root as listed by RTLIST
$NSVD
Number of root as listed by SVDLIST
$OFFSET_1D
spectral offset in 1D (in Hz)
$OFFSET_1_2D
spectral offset in 2D in F1 (in Hz)
$OFFSET_1_3D
spectral offset in 3D in F1 (in Hz)
$OFFSET_2_2D
spectral offset in 2D in F2 (in Hz)
$OFFSET_2_3D
spectral offset in 3D in F2 (in Hz)
$OFFSET_3_3D
spectral offset in 3D in F3 (in Hz)
$ORDER
current value for ORDER
$PH0
0th order of the last phase correction
$PH1
1st order of the last phase correction
$PK1D_A[i]
amplitude of the ith entry in the 1D peak table
$PK1D_F[i]
position (in index) of the ith entry in the 1D peak table
$PK1D_P[i]
phase of the ith entry in the 1D peak table
$PK1D_W[i]
width (in index) of the ith entry in the 1D peak table
$PK2D_A[i]
amplitude of the ith entry in the 2D peak table
$PK2D_ERR[i]
amplitude error as reported by INTEG.
$PK2D_F1F[i]
F1 position (in index) of the ith entry in the 2D peak table
$PK2D_F1W[i]
F1 width (in index) of the ith entry in the 2D peak table
$PK2D_F2F[i]
F2 position (in index) of the ith entry in the 2D peak table
$PK2D_F2W[i]
F2 width (in index) of the ith entry in the 2D peak table
$PK3D_A[i]
amplitude of the ith entry in the 3D peak table
$PK3D_F1F[i]
F1 position (in index) of the ith entry in the 3D peak table
$PK3D_F1W[i]
F1 width (in index) of the ith entry in the 3D peak table
$PK3D_F2F[i]
F2 position (in index) of the ith entry in the 3D peak table
$PK3D_F2W[i]
F2 width (in index) of the ith entry in the 3D peak table
$PK3D_F3F[i]
F3 position (in index) of the ith entry in the 3D peak table
$PK3D_F3W[i]
F3 width (in index) of the ith entry in the 3D peak table
$PKNAME
The name used by the last PKREAD / PKWRITE command
$PLANE[1]
axis of the last extracted plane in 3D
$PLANE[2]
index of the last extracted plane in 3D
$PLOTAXIS[1]
current value for the unit used in PLOTAXIS
$PLOTAXIS[2]
current value for the tick distance in x axis
$PLOTAXIS[3]
current value for the tick distance in y axis
$PLOTOFFSET[1]
current value for plot offset on X axis
$PLOTOFFSET[2]
current value for plot offset on Y axis
$POINTX[i]
X coordinates (in index) of ith point in the point stack
$POINTY[i]
Y coordinates (0..1 in 1D; in index if 2D) of ith point in the point stack
$RANDOM
a random variable in the range 0..1 with equiprobable distribution
$RANDOMG
a random variable with normal law, unit variance and zero mean
$RANDOMZ
same as $RANDOM but resets the random series
$RELAX
the result of the last RELAXRATE or SLOPE commands
$RCRYST
the result of the last RCRYST command CALIBDI
$ROW
index of the last extracted row in 2D
$SCALE
current value of the context SCALE
$SCOLOR
current value of the context SCOLOR
$SHIFT
value of the offset, as given by the SHIFT command
$SI1_1D
size of the 1D buffer.
$SI1_2D
size in F1 of the 2D buffer
$SI1_3D
size in F1 of the 3D buffer
$SI2_2D
size in F2 of the 2D buffer
$SI2_3D
size in F2 of the 3D buffer
$SI3_3D
size in F3 of the 3D buffer
$SIGN
current value of command SIGN
$SPECW_1D
spectral width in 1D (in Hz)
$SPECW_1_2D
spectral width in 2D in F1 (in Hz)
$SPECW_1_3D
spectral width in 3D in F1 (in Hz)
$SPECW_2_2D
spectral width in 2D in F2 (in Hz)
$SPECW_2_3D
spectral width in 3D in F2 (in Hz)
$SPECW_3_3D
spectral width in 3D in F3 (in Hz)
$SUMREC
value returned by the last SUMREC command
$UNIT
current value for UNIT
$VAR_MAX
The total number of user variable available, as returned by the CONFIG command
$VERSION
The current version, as returned by the CONFIG command
$VHEIGHT
current value of command VHEIGHT
$WIDGET
The id of the current graphic form
$ZONE[1]
lower F1 coord. of the mouse-selected region (in index)
$ZONE[2]
lower F2 coord. of the mouse-selected region (in index)
$ZONE[3]
upper F1 coord. of the mouse-selected region (in index)
$ZONE[4]
upper F2 coord. of the mouse-selected region (in index)
$ZOOM
1 if in ZOOM mode
$ZOOM_1D[1]
left coordinate of the 1D zoom window (in index)
$ZOOM_1D[2]
right coordinate of the 1D zoom window (in index)
$ZOOM_2D[1]
lower F1 coordinate of the 2D zoom window (in index)
$ZOOM_2D[2]
left F2 coordinate of the 2D zoom window (in index)
$ZOOM_2D[3]
upper F1 coordinate of the 2D zoom window (in index)
$ZOOM_2D[4]
right F2 coordinate of the 2D zoom window (in index)
$ZOOM_3D[1]
"left" F1 coordinate of the 3D zoom window (in index)
$ZOOM_3D[2]
"right" F1 coordinate of the 3D zoom window (in index)
$ZOOM_3D[3]
"left" F2 coordinate of the 3D zoom window (in index)
$ZOOM_3D[4]
"right" F2 coordinate of the 3D zoom window (in index)
$ZOOM_3D[5]
"left" F3 coordinate of the 3D zoom window (in index)
$ZOOM_3D[6]
"right" F3 coordinate of the 3D zoom window (in index)


Prev Next Title Contents