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

Home » Public Forums » archive » Re: type conversion error - help needed urgent
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: type conversion error - help needed urgent [message #84444] Mon, 27 May 2013 14:33
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Craig Markwardt writes:

> This is like giving gasoline and a match to a boyscout learning to build a fire.

My thought, exactly! :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: type conversion error - help needed urgent [message #84446 is a reply to message #84444] Mon, 27 May 2013 14:17 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Monday, May 27, 2013 5:28:48 AM UTC-4, fawltyl...@gmail.com wrote:
> On Monday, May 27, 2013 10:42:41 AM UTC+2, Mats Löfdahl wrote:
>> IDL> void=execute('whatever='+varstr)
>>
>> I'll probably correct this again in a couple of minutes...
>
> (SCOPE_VARFETCH('whatever', /ENTER))=SCOPE_VARFETCH(varstr)

This is like giving gasoline and a match to a boyscout learning to build a fire.
Re: type conversion error - help needed urgent [message #84460 is a reply to message #84446] Mon, 27 May 2013 02:28 Go to previous message
Lajos Foldy is currently offline  Lajos Foldy
Messages: 176
Registered: December 2011
Senior Member
On Monday, May 27, 2013 10:42:41 AM UTC+2, Mats Löfdahl wrote:

> IDL> void=execute('whatever='+varstr)
>
> I'll probably correct this again in a couple of minutes...

(SCOPE_VARFETCH('whatever', /ENTER))=SCOPE_VARFETCH(varstr)

regards,
Lajos
Re: type conversion error - help needed urgent [message #84461 is a reply to message #84460] Mon, 27 May 2013 01:42 Go to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den måndagen den 27:e maj 2013 kl. 10:36:37 UTC+2 skrev sid:
> On Monday, May 27, 2013 1:35:02 PM UTC+5:30, Mats Löfdahl wrote:
>
>> Den måndagen den 27:e maj 2013 kl. 10:02:32 UTC+2 skrev Mats Löfdahl:
>
>>> Or in your case,
>
>>> IDL> void='whatever=varstr'
>
>> No, that was someone else's case. In YOUR case, it would be
>
>> IDL> void='whatever='+varstr
>
> Thank you very much sir. I was struggling for so much time. It works fantastically.
>
> Thanking you a lot

It's great that you got what I meant, in spite of my failure to make the final line come out right. For reference, what I meant to write was:

IDL> void=execute('whatever='+varstr)

I'll probably correct this again in a couple of minutes...
Re: type conversion error - help needed urgent [message #84462 is a reply to message #84461] Mon, 27 May 2013 01:36 Go to previous message
gunvicsin11 is currently offline  gunvicsin11
Messages: 93
Registered: November 2012
Member
On Monday, May 27, 2013 1:35:02 PM UTC+5:30, Mats Löfdahl wrote:
> Den måndagen den 27:e maj 2013 kl. 10:02:32 UTC+2 skrev Mats Löfdahl:
>
>>
>
>> Or in your case,
>
>>
>
>> IDL> void='whatever=varstr'
>
>
>
> No, that was someone else's case. In YOUR case, it would be
>
>
>
> IDL> void='whatever='+varstr

Thank you very much sir. I was struggling for so much time. It works fantastically.
Thanking you a lot
sid
Re: type conversion error - help needed urgent [message #84463 is a reply to message #84462] Mon, 27 May 2013 01:05 Go to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den måndagen den 27:e maj 2013 kl. 10:02:32 UTC+2 skrev Mats Löfdahl:
>
> Or in your case,
>
> IDL> void='whatever=varstr'

No, that was someone else's case. In YOUR case, it would be

IDL> void='whatever='+varstr
Re: type conversion error - help needed urgent [message #84464 is a reply to message #84463] Mon, 27 May 2013 01:02 Go to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Måndagen den 27:e maj 2013 kl. 06:50:45 UTC+2 skrev sid:
>
> But still the problem is not solved since varstr is equal to jplm10(34) which is a string , so I am not getting value of jplm10(34)

Your program might be faster and easier to read if you had a 2D array, so instead if jplmN(M), you could use jplm(N,M). But if you want to continue with the idea of constructing the variable name as a string, I think you want the execute command:

IDL> a=findgen(10)
IDL> void=execute('c=a(8)')
IDL> print,c
8.00000

Or in your case,

IDL> void='whatever=varstr'

http://www.exelisvis.com/docs/EXECUTE.html
Re: type conversion error - help needed urgent [message #84465 is a reply to message #84464] Sun, 26 May 2013 21:50 Go to previous message
gunvicsin11 is currently offline  gunvicsin11
Messages: 93
Registered: November 2012
Member
On Monday, May 27, 2013 12:01:50 AM UTC+5:30, David Fanning wrote:
> sid writes:
>
>
>
>> jplm10(34)
>
>
>
> IDL> varstr = 'jplm' + StrTrim(v,2) + '(' + StrTrim(dpi[0],2) + ')'
>
>
>
>> I need to use this value for further calculations but this is taken as a string and the variable couldnt be used.
>
>
>
> Humm. Kind of a strange way to write a program, but maybe you know what
>
> you are doing. :-)
>
>
>
> Cheers,
>
>
>
> David
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Hello sir,
But still the problem is not solved since varstr is equal to jplm10(34) which is a string , so I am not getting value of jplm10(34)

Actually,
IDL> help,jplm10(34)
<Expression> FLOAT = 6502.00

But this varstr

IDL> help,varstr
VARSTR STRING = 'jplm10(34)'

But from this I am getting jplm10(34) but it is a string so If take it as a variable then this type conversion error comes.
Please help me in this regard
thanking you
sid
Re: type conversion error - help needed urgent [message #84470 is a reply to message #84465] Sun, 26 May 2013 11:31 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
sid writes:

> jplm10(34)

IDL> varstr = 'jplm' + StrTrim(v,2) + '(' + StrTrim(dpi[0],2) + ')'

> I need to use this value for further calculations but this is taken as a string and the variable couldnt be used.

Humm. Kind of a strange way to write a program, but maybe you know what
you are doing. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: on the background color of cgplot
Next Topic: Re: contour discontinuity

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

Current Time: Wed Oct 08 11:42:01 PDT 2025

Total time taken to generate the page: 0.00473 seconds