spec

Software for Diffraction

1.3.4. - Using Variables



spec's variables can be used as both strings and as double-precision floating-point numbers. Variables are not declared, but come into existence through usage. Some variables are built-in, though, and of these, some have preassigned values. The variable PI is an example.
1.FOURC> {
2.more> k = 2 * PI / 1.54
3.more> print k
4.more> }
4.07999 5.FOURC>

Curly brackets ({ and }) are used to delimit a block to be interpreted together, since variables are local to interpreted blocks. Notice that the prompt indicates the program is expecting further input before interpreting and taking action.
1.FOURC> print k
0 2.FOURC>

The value of k disappeared because k was local to the previous statement block. New variables start off with a value of zero.

A variable may be declared global to hold its value outside an interpreted block:
1.FOURC> global Lambda CuKa
2.FOURC> Lambda = 1.54
3.FOURC> CuKa = "Copper K-alpha
4.FOURC> print CuKa, "=", Lambda
Copper K-alpha = 1.54 5.FOURC>



By convention, global variables in the standard macro package use capital letters or begin with an underscore. Variables can be made constant to protect them from accidental reassignment,
1.FOURC> constant Lambda 1.54
2.FOURC> Lambda = 1.7
Trying to assign to a constant `Lambda'. 3.FOURC>

Variables defined as constant are automatically global.

Most built-in variables with preassigned values are of the immutable type and cannot be changed at all:
1.FOURC> PI = 1
Trying to assign to an immutable `PI'. 2.FOURC>

Some built-in variables, such as DEBUG, can be changed by the user. Another variable, the A[] array, may be filled by the program with the current motor positions or can be set to target motor positions. For a list of all current symbols, type:
1.FOURC> syms
( Built-In/Global/Local Array Number String Constant/Immutable ) 8256 A (BA...) 80 SLIT_W (G.NS.) 80 _f1 (G.NS.) 96 ADMIN (G..S.) 96 SPEC (B..SI) 80 _f2 (G.NS.) 80 BG (G.N..) 112 SPECD (B..SI) 80 _f3 (G.NS.) 96 COLS (B.N..) 80 TEMP_CS (G.NS.) 80 _fx (G.NS.) 80 COUNT (G.N..) 80 TEMP_SP (G.NS.) 80 _g1 (G.NS.) 96 COUNTERS (B.N.I) 96 TERAMP_MIN (G.N..) 80 _g2 (G.NS.) 96 COUNT_TIME (G.NS.) 96 TERM (B..S.) 96 _hkl_col (G.N.C) 128 CP_FILTER (G..S.) 80 TIME (G.NS.) 80 _m (G.NS.) 112 CWD (B..SI) 96 TIME_END (G.NS.) 80 _m1 (G.NS.) 128 DATAFILE (G..S.) 96 TITLE (G..S.) 80 _m2 (G.NS.) 112 DATA_DIR (G..S.) 80 T_AV (G.NS.) 80 _m3 (G.NS.) 80 DATE (G.NS.) 80 T_HI_SP (G.N..) 80 _n1 (G.NS.) 80 DEBUG (B.N..) 80 T_L (G.NS.) 80 _n2 (G.NS.) 80 DEGC (G.NS.) 80 T_LO_SP (G.N..) 80 _nm (G.NS.) 80 DEGC_SP (G.NS.) 2736 U (BA...) 80 _numgeo (G.N..) 80 DET (G.N..) 1056 UB (BA...) 80 _pmot (G.NS.) 80 DOFILE (G.NS.) 592 UNITS (GA...) 96 _pmotflag (G.NS.) 96 DO_DIR (G..S.) 80 UPDATE (G.N..) 96 _pre_chk (G.N..) 80 EPOCH (G.N.C) 96 USER (B..SI) 80 _pwid (G.NS.) 80 FPRNT (G.NS.) 96 USER_CHK_ACQ (G.NS.) 80 _reg_f (G.NS.) 1296 G (BA...) 96 USER_CHK_COUNT (G.NS.) 80 _reg_i (G.NS.) 96 GS_file (G..S.) 96 USER_CHK_MOVE (G.NS.) 80 _reg_n (G.NS.) 80 GS_scan (G.N..) 80 VFMT (G.NS.) 80 _reg_s (G.NS.) 80 GS_xcol (G.N..) 80 VPRNT (G.NS.) 112 _reg_scan (G..S.) 80 GS_ycol (G.N..) 80 X_L (G.NS.) 80 _reg_t (G.NS.) 96 GTERM (B..S.) 80 Y_L (G.NS.) 80 _s (G.NS.) 80 HEADING (G.NS.) 816 Z (BA...) 80 _s1 (G.NS.) 112 HOME (B..SI) 80 _1 (G.N..) 80 _s2 (G.NS.) 96 MAIL (G..S.) 80 _2 (G.NS.) 80 _s3 (G.NS.) 80 MODES (G.N.C) 80 _3 (G.NS.) 80 _sleep (G.NS.) 80 MON (G.N..) 80 _4 (G.NS.) 80 _stime (G.NS.) 96 MON_RATE (G.NS.) 80 _5 (G.NS.) 80 _stype (G.NS.) 80 MOTORS (B.N.I) 80 _6 (G.NS.) 80 _sx (G.NS.) 80 MT_AV (G.NS.) 80 _7 (G.NS.) 96 _upd_flg (G.NS.) 80 NPTS (G.NS.) 80 _8 (G.NS.) 80 bg_m (G.NS.) 80 PFMT (G.NS.) 80 _9 (G.NS.) 80 bg_pts (G.N..) 80 PI (B.N.I) 80 _LAMBDA (G.NS.) 80 bg_yI (G.NS.) 96 PLOT_MODE (G.N..) 96 _bad_lim (G.NS.) 80 chi (B.N.I) 80 PL_G (G.N..) 80 _c1 (G.NS.) 96 chk_thresh (G.NS.) 80 PL_G1 (G.N..) 80 _c2 (G.NS.) 80 det (B.N.I) 80 PL_X (G.N..) 80 _c3 (G.NS.) 1184 gmodes (GA...) 80 PL_Y (G.N..) 80 _c4 (G.NS.) 656 mA (GA...) 80 PPRNT (G.NS.) 80 _cols (G.NS.) 80 mon (B.N.I) 112 PRINTER (G..S.) 80 _const (G.NS.) 80 phi (B.N.I) 1856 Q (BA...) 80 _cp (G.NS.) 128 rplot_col (G..S.) 80 REFLEX (G.NS.) 80 _ctime (G.NS.) 80 sec (B.N.I) 80 ROWS (B.N..) 80 _d (G.NS.) 128 splot_col (G..S.) 10576 S (BA...) 80 _d1 (G.NS.) 80 th (B.N.I) 80 SCAN_N (G.NS.) 80 _d2 (G.NS.) 80 tth (B.N.I) 80 SLIT_H (G.NS.) 80 _d3 (G.NS.) 80 SLIT_N (G.N.C) 80 _f (G.NS.) Memory usage is 41088 bytes. 2.FOURC>

The number preceding each name is the number of bytes of memory the variable consumes. All the global variables in the list above come from the standard start-up macro files. Those variables that begin with an underscore are internal to the standard macro package.