User Tools

Site Tools


jvs:fscan:manual:chapter1:stringsubst

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
jvs:fscan:manual:chapter1:stringsubst [2014/08/04 16:03]
127.0.0.1 external edit
jvs:fscan:manual:chapter1:stringsubst [2023/02/23 18:43] (current)
Line 1: Line 1:
 **fScan Reference Manual, Chapter 1 (Topics): stringsubst** **fScan Reference Manual, Chapter 1 (Topics): stringsubst**
-===== stringsubst -- =====+===== string substitution -- Using string variables in fScan commands =====
  
- stringsubst -- find and substitute string variables (including XML keywords) +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 commandsbut they can be used anytime.
-        If MAXC > 0substitution is done in-place.+
  
-variable      $varbname +There are 3 types of string variables: 
-                        ${varbname}+  * 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
  
-variable+const +Set USER variables using the [[jvs:fscan:manual:chapter2:set|SET]] command as:\\ 
-variable-const +   set varb1 = value1 
-variable*const +   set varb2 value2 
-variable/const+   set accept varb3 "Enter VARB3 value"
  
-varbname      varbname +For example:\\ 
-                        uservarb +  set myname "Henry
- +  set fullname "Henry Higgens
- [rest has not been implemented yet] +  set myage 42
-                        dataname::xmlspec                       + +
-                        xmlspec +
-dataname:       datasetname +
-                        filename +
-xmlspec:        elementname +
-                        namespace:elementname +
-                        xmlspec/xmlspec +
-                        xmlspec/attribute +
-                        xmlspec[numvalue] +
-attribute:      @attributename="string+
-                        @attributename=string           + +
- +
-+: not standard XPath +
- +
- +
-Examples: +
-        $taskname +
-        $xdim/2 +
- +
-        ${mrfile::bxh:datarec/@type="imagedata"/dimensions/@type="x"/size} +
- +
-Set USER variables using the -SET command as: +
--set uservarb = value +
--set uservarb value+
  
 +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:**\\ **See Also:**\\
 +[[jvs:fscan:manual:chapter2:set|SET command]] 
  
 [[jvs:fscan|fScan Home]],  [[jvs:fscan|fScan Home]], 
jvs/fscan/manual/chapter1/stringsubst.1407168181.txt.gz · Last modified: 2014/08/04 16:03 by 127.0.0.1