Re: Removing CRLF from a String [message #11363 is a reply to message #11344] |
Fri, 20 March 1998 00:00  |
David Burridge
Messages: 33 Registered: January 1998
|
Member |
|
|
Jeff,
Are you sure that it's the CR that is the problem? From your example I
don't.
I see this message a lot when I'm testing a variable that has been
extracted from an array or that comes from a routine that can return
arrays. It normally means that you've got an 1 element array of strings, as
opposed to just a string (doing a help on "filename" and "directoryname"
confirms this).
To cure the problem, use REFORM to remove dimensions of 1 from the array:
filename = REFORM (filename)
BTW: To get IDL to crash (and help with your debugging), type XMANAGER,
CATCH=0 at the prompt. Don't forget to RETALL and XMANAGER after a crash,
though - just like you used to IDL 4!
Cheers,
Dave
Jeff <jeffe@fl.ensco.com> wrote in article
<351154EA.A6AD4CD5@fl.ensco.com>...
> IDL was outputting the following message to me:
>
> % XMANAGER: Caught unexpected error from client application. Message
> follows...
> % MESSAGE: Expression must be a scalar in this context: <STRING
> Array[1]>.
>
> After tracking down what it really meant, I found that the fileName
> I was passing to the READ_ASCII routine had a CR at the end of it.
> (Boy I wish it returned a line number or Procedure where it bombed)
>
> I am using the CW_FIELD to get the string, so I do I avoid getting
> the CR, or how do I remove it.
>
> I've tried STRTRIM but it leaves CR's.
> I've tried using a WIDGET_TEXT rather than a CW_FIELD but get the
> same results.
>
> My simple example program is attached.
>
> Thanks,
>
> Jeff
|
|
|