Code cluttered with 'STRTRIM(variable,2)' ? [message #5010] |
Wed, 13 September 1995 00:00 |
Russ Welti
Messages: 27 Registered: October 1994
|
Junior Member |
|
|
A nit that has plagued me since day 1 in IDL is:
What is the best way to formulate strings which contain
variables' values without getting all cluttered up with
strtrim(variable,2) ?? This really uglifies my code.
Example:
> msg=$
> 'Warning: '+strtrim(n_sizes,2)+' size combinations fitted against '+$
strtrim(n_peaks,2)+' peak combinations means '+ $
strtrim(n_sizes*n_peaks,2)+' individual curve fits will be done.'
> print,msg
I have played with PRINT,STRING(FORMAT='( . . . )',<stuff>)
but that is not really very nice to look at either and is a pain
to maintain the format spec if the output changes slightly.
I guess possible solutions include defining a 'wrapper' for
strtrim, like:
FUNCTION str,s
return,strtrim(s,2)
END
Any thoughts? Am I missing an easy way?
I think the default, for a function called stringTRIM, should be
to trim both ends, so at least I would not need to pass that pesky 2. ;)
/
Russ Welti /-\
(c-g)
University of Washington \-/
Molecular Biotechnology /
PO Box 352145 /-\
Seattle, WA 98195 (a-t)
rwelti@u.washington.edu \-/
|
|
|