USAGE (Fortran):

      CALL REPLACE_ENVARS_L (string)

PURPOSE:

Replace environment parameters in string

Where string contains `$VAR ´, this substring will be replaced by the value of environment variable VAR if defined, else the string will be contracted such that `$VAR´ disappears.
If the substring is not right-delimited with a blank, the following format must be used: ${VAR}.

The ${...} form can be extended to define a default value: ${VAR:[default]}

Dollar signs can be escaped:                       $$

Repeated replacement ("Russian doll") is possible:                  \${name:[$anothername:[default]}
(Obs! only one right bracket+brace)

A number of HGS' Fortran programs make use of this mechanism. Note that

Example in
tsfedit command lines:

    SIN ${AMP:[1.0]} ${FREQ:[100.0]} ${PHA:[0.0]} [mHz]

Example:

prompt> setenv FILE abcd

A tse-file (instructions to tsfedit, called by tslist) may contain
OPEN 31 < ${FILE}.ts

The program will open a file named  `abcd.ts´


Example 2, with defaults:
prompt> echo $FILEA
FILEA: Undefined variable.

OPEN 31 < ${FILEA:[output]}.ts

The program will open a file named  `output.ts´


Example 3, with defaults:
prompt> setenv COMMENT "Guten Abend"
prompt> setenv FNQ tst4.ts

OPEN 34 < ${FNQ}${COMMENT:[Hello]} friends

The protocol output will read
 <TsfEdi>C> OPEN 34 < tst4.tsGuten Abend friends ;
 <TsfEdi>>> ---> CALL OPENFS:   4 34 < tst4.tsGuten Abend friends
 <OPENF->3> 34:< tst4.tsGuten                         - Abend friends

so that
OPEN 34 < ${FNQ} ${COMMENT:[Hello]} friends
would have made more sense (obs. the blank after `${FNQ}´!)

Example 4, "Russian doll" replacement:

 ~/sas/p/mt/testenv.tse
TSF EDIT E
NOOP \${HELLO:[${YOU:[ME]}
NOOP $$HELLO
END

prompt> tslist _100 -B2017,1,1 -r1 -Etestenv.tse,E -I

Try yourself to setenv values for  HELLO , YOU , and ME


.bye