**fScan Reference Manual, Chapter 1 (Topics): stringsubst** ===== string substitution -- Using string variables in fScan commands ===== Character string variables are identified by preceding the variable name with a '$' or '_' character. String variables are replaced by their text during command execution. String variables can also be used to perform simple arithmetic functions. String variables are most useful when writing scripted macros or creating menu commands, but they can be used anytime. There are 3 types of string variables: * preset global variables - fScan control variables (e.g. $fscanhome, $opsys) * data descriptor variables - current image meta-data (e.g. $tr, $xdim) * user-defined variables - obvious Set USER variables using the [[jvs:fscan:manual:chapter2:set|SET]] command as:\\ set varb1 = value1 set varb2 value2 set accept varb3 "Enter VARB3 value" For example:\\ set myname "Henry" set fullname "Henry Higgens" set myage 42 Variable names are identified by an initial '$' or '_' character. Either prefix can be used for any variable; the variable is replaced by its string value in both cases. The '_' identifier is recommended if you are specifying a string variable on a fScan command line because the '$' character means something different to shell command interpreters. Otherwise the '$' and '_' identifiers behave identically for single-valued variables. But if the variable contains multiple words (separated by spaces) then a single '$' variable argument in a command will be converted to multiple single-word arguments, whereas a '_' multi-word variable argument remains a single argument. To perform simple arithmetic simply follow a variable name with '+', '-', '*', or '/' and a number value (no spaces). For example set newage $myage+3 echo "Image center location is:" $xdim/2 $ydim/2 $zdim/2 **See Also:**\\ [[jvs:fscan:manual:chapter2:set|SET command]] [[jvs:fscan|fScan Home]], [[jvs:fscan:manual|fScan Manual]], [[jvs:fscan:manual:chapter1|Topics]], [[jvs:fscan:manual:help|Manual Help]]