Strings

All string FISH functions are indexed in the FISH Reference.

A common use of strings in FISH functions is to control interactive input and output. The following example illustrates this for user-supplied input parameters for Young’s modulus and Poisson’s ratio:


new
def in_def
  xx = io.in(msg+'('+'default:'+string(default)+'):')
  if type(xx) = 3
    in_def = default
  else
    in_def = xx
  endif
end
def moduli_data
  default = 1.0e9
  msg='Input Young`s modulus '
  y_mod = in_def
  default = 0.25
  msg='Input Poisson`s ratio '
  p_ratio = in_def
  if p_ratio = 0.5 then
    io.out(' Bulk mod is undefined at Poisson`s ratio = 0.5')
    io.out(' Select a different value --')
    p_ratio = in_def
  endif
  s_mod = y_mod / (2.0 * (1.0 + p_ratio))
  b_mod = y_mod / (3.0 * (1.0 - 2.0 * p_ratio))
end
@moduli_data
list @y_mod @p_ratio
list @s_mod @b_mod

The only arithmetic operation that is valid for string variables is addition. As seen in the example above, this causes two strings to be concatenated.

The table below identifies special characters available in string manipulation:


Table 1: String Manipulation Characters
' place single quote in string
" place double quote in string
\b backspace
\t tab
\r carriage return
\n CR/LF

An arithmetic operation cannot have only one argument that is a string variable. The intrinsic function string() must be used if a number is to be included as part of a string variable (see variable xx in the example shown above). Also note the use of intrinsic function type(), which identifies the type of argument.