comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Code cluttered with 'STRTRIM(variable,2)' ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Code cluttered with 'STRTRIM(variable,2)' ? [message #5008 is a reply to message #5007] Thu, 14 September 1995 00:00 Go to previous message
zawodny is currently offline  zawodny
Messages: 121
Registered: August 1992
Senior Member
Russ Welti <rwelti@chroma.mbt.washington.edu> writes:
>
> 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 agree with your concept. IDL should be able to autoconvert
variables to the appropriate type. In fact it does this all the time
in mathematical and logical expressions such as a = 1.+2, a will be
real. IDL convert variables of different types to the same type
(according to certain rules used to establish priority) before doing
the math.

To see what is going on in the example above, I did a brief test.

IDL> print,'test '+1
% Type conversion error: Unable to convert given STRING to Integer.
% Detected at: $MAIN$
1

This tells me that IDL was trying to convert the string to an integer
rather than the integer to the string. The logic for the test of a
type mismatch is already in IDL, it just tried to do the "wrong"
conversion. I would think that in the case of a variable type
mismatch involving strings that IDL should default to converting
everything to string type and that it should be done in the same manner
as a STRTRIM(var,2) call would do. Perhaps there are others out there
who would prefer the other type of behavior. Is the default of
converting strings to numbers an artifact of the need to do such a
thing during the reading of an ASCII file? If so, could we (you - RSI)
separate the two processes and thereby make STRTRIM nearly obsolete?

Thoughts, comments, or corrections?

--
Dr. Joseph M. Zawodny KO4LW NASA Langley Research Center
E-mail: J.M.Zawodny@LaRC.NASA.gov MS-475, Hampton VA, 23681-0001
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL and Windows 95
Next Topic: Please help! Want N-D wavelets in PV-WAVE

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:19:27 PDT 2025

Total time taken to generate the page: 0.00519 seconds