## -*-SM-*- Set SM-mode in emacs ang ## set angle angle bo 01 ## draw a box, only labelling external axes in windows # For this to work, you must have used wind not window, # or overloaded window to wind (i.e. OVERLOAD WINDOW 1 # MACRO window { wind } ) This is done by set_overload # If box is not the last command on the line, it'll # just call BOX if($?1 == 0 && $?_nx && $?_ny && $?_ix && $?_iy) { DO 5=1,4 { DEFINE $5 0 } if($_nx > 0) { # boxes don't touch in x DEFINE 2 2 } ELSE { IF(atof('$_ix') == 1) { DEFINE 2 2 } ELSE { IF(atof('$_ix') == -$_nx) { DEFINE 4 2 } } } if($_ny > 0) { # boxes don't touch in y DEFINE 1 1 } ELSE { IF(atof('$_iy') == 1) { DEFINE 1 1 } ELSE { IF(atof('$_iy') == -$_ny) { DEFINE 3 1 } } } BOX $1 $2 $3 $4 RETURN } if($?1 == 0) { BOX RETURN } BOX $1 con ## connect a line connect cur ## cursor cursor da 1 ## set data file DATA "$!1" dev 1 ## set device if('$1' != 'meta' && '$1' != 'META') { del1 DEFINE device $1 } DEVICE $1 dr ## draw dra dra 2 ## draw, accepting expressions DEFINE 1 ($1) DEFINE 2 ($2) DRAW $1 $2 ec ## ecolumn ecolumn ecolumn ## define vector error_col as error vector read error_col end ## quit, not on history del1 QUIT era ## erase screen, not on history del1 ERASE err ## errorbar errorbar ex ## expand expand lim ## limits limits lin ## lines lines lty ## ltype ltype hard 01 ## make a hardcopy of what you type (or get by history) # hard [ printer ] if($?1 == 0) { IF($?PRINTER == 0) { DEFINE PRINTER : } IF($?PRINTER == 0) { echo You must specify a printer RETURN } DEFINE 1 $PRINTER } echo "Type commands, end with ^X" MACRO EDIT __junk__ hmacro __junk__ $1 MACRO __junk__ DELETE hardcopy ## close the old device and set dev type to 0 DEVICE 0 hcopy 03 ## hcopy [printer] [l1] [l2]: Make hardcopy of playback buffer # optionally specify which printer ($1) and which lines ($2-$3) # if the printer ($1) is omitted (i.e. $1 is missing or a # number), it will be taken from the value of the environment # variable PRINTER, if defined. IF($?printer == 0) {DEFINE printer ? { what kind of printer? }} IF($?1) { IF(WHATIS($1) == 0) { # a number if($?2) { DEFINE 3 $2 } DEFINE 2 $1 DEFINE 1 DELETE } } IF($?1) { DEVICE $printer $1 } ELSE { IF($?PRINTER == 0) { DEFINE PRINTER : } # which one? IF($?PRINTER) { DEVICE $printer $PRINTER } ELSE { DEVICE $printer } } IF($?2 == 0) { DEFINE 2 0 DEFINE 3 10000 } ELSE { IF($?3 == 0) { DEFINE 3 $2 } } playback $2 $3 \n DEVICE $device bell hmacro 02 ## hmacro [macro] [printer] : make hardcopy of `macro' on `printer' # If only 1 argument is present, it is taken to be the printer # unless an environment PRINTER variable is defined, when # that's used as a printer, and the arg. is taken to be a macro # If no macro is specified, make a temp one IF($?printer == 0) {DEFINE printer ? { what kind of printer? }} IF($?2 == 0) { # only one arg IF($?PRINTER == 0) { DEFINE PRINTER : } IF($?PRINTER) { DEFINE 2 $PRINTER } } IF($?1) { if($?2) { # 2 args DEFINE _mac $1 DEFINE _temp 0 # no temp macro } ELSE { # 1 arg, take as printer DEFINE 2 $1 # printer DEFINE _temp 1 # need temp macro } } ELSE { # no $1 IF($?2 == 0) { DEFINE 2 " " } DEFINE _temp 1 # need temp macro } IF($_temp) { DEFINE _mac _mac echo "Create temporary macro, exit with ^X" MACRO EDIT $_mac IF(is_macro($_mac) == 0) { DEFINE _mac DELETE DEFINE _temp DELETE RETURN } } DEVICE $printer $2 del1 $_mac \n DEVICE $device IF($_temp) { MACRO $_mac DELETE } DEFINE _mac DELETE DEFINE _temp DELETE bell hi ## histogram histogram hist ## histogram histogram id ## put ID at top of plot identification identification ## write an id to the top right hand corner of screen RELOCATE ( 32000 32400 ) if($?TeX_strings) { define 1 {\-2\t } } else { DEFINE 1 {\\-2\\t} } define 2 " " if($?x_col) { if('$x_col' != '.') { define 2 <$2""X: $x_col > } } if($?y_col) { if('$y_col' != '.') { define 2 <$2""Y: $y_col > } } PUTLABEL 4 $1File: $(quote_TeX('$data_file'))$2: \ $(substr('$!date',0,12) + substr('$!date',15,0)) inp ## input -- i.e. read and execute a Mongo (not SM) file input input 1 ## read and execute a Mongo (not SM) file if(!$?_input_level) { local define _input_level 0 } define _input_level ($_input_level + 1) READ OLD _temp$_input_level $1 _temp$_input_level MACRO _temp$_input_level DELETE # inp_new ## read and execute an SM file of commands (1 per line) input_new input_new 1 ## read and execute an SM file of commands (1 per line) if(!$?_input_level) { local define _input_level 0 } define _input_level ($_input_level + 1) # MACRO all$_input_level 0 10000 # save history DELETE 0 10000 RESTORE $1 # read commands define 3 5 # maximum nesting for input MACRO _temp$_input_level 0 10000 DELETE 0 10000 WRITE HISTORY all$_input_level # restore history _temp$_input_level MACRO _temp$_input_level DELETE MACRO all$_input_level DELETE # lt ## ltype ltype lw ## lweight lweight mongo # make SM resemble Mongo as closely as possible load abbrev DEFINE TeX_strings DELETE compatible page # start a new page for hardcopy devices ERASE pc ## pcolumn (Mongo) pcolumn pcolumn 1 ## set point column (Mongo) READ ptype_col $1 PTYPE ptype_col SET HELP ptype_col Column $1 from $data_file play ## playback playback playback 02 ## define "all" from buffer, and run it # with args, only playback those lines del1 # remove the "playback" MACRO all {} WRITE HISTORY all # and replace with "" IF($?1 == 0) { DEFINE 1 0 DEFINE 2 10000 } ELSE { IF($?2 == 0) { DEFINE 2 $1 } } MACRO all $1 $2 del1 all poi ## points points pt ## ptype ptype putl ## putlabel putlabel read_all 1 ## read a macro file, putting `all' onto the history buffer del1 echo Writing `all' onto the end of the playback buffer MACRO READ $1 WRITE HISTORY all read_hist ## read history from a file read_all read_old 1 ## read an Mongo file onto the history buffer del1 READ OLD _temp $1 WRITE HISTORY _temp MACRO _temp DELETE rel 2 ## relocate, accepting expressions DEFINE 1 ($1) DEFINE 2 ($2) RELOCATE $1 $2 save_all 1 ## write the playback list to a file (use sav instead) del1 MACRO all 0 1010100 MACRO WRITE all $1 term ## device device terminal ## device device ti ## ticksize ticksize toplabel ## put label at top of plot RELOCATE ( 17600 32300 ) putlabel 5 wind 4 ## like window, but store values as variables IF($1 != 1 || $2 != 1) { DEFINE _nx $1 DEFINE _ny $2 DEFINE _ix "$!3" DEFINE _iy "$!4" } ELSE { FOREACH _i ( _nx _ny _ix _iy ) { IF($?$_i) { DEFINE $_i DELETE } } } WINDOW $1 $2 $3 $4 xc ## xcolumn xcolumn xcolumn 1 ## read a column into vector x (Mongo) IF($1 <= 0) { del1 READ x $1 } ELSE { READ x $1 DEFINE x_col $1 SET HELP x Column $1 from $data_file } xla ## xlabel xlabel xlog ## xlogarithm xlogarithm xlogarithm ## take log of vector x (Mongo) SET x=LG(x) yc ## ycolumn ycolumn ycolumn 1 ## read a column into vector y (Mongo) IF($1 <= 0) { del1 READ y $1 } ELSE { READ y $1 DEFINE y_col $1 SET HELP y Column $1 from $data_file } yla ## ylabel ylabel ylog ## ylogarithm ylogarithm ylogarithm ## take log of vector y SET y=LG(y)