Re: the type parser [message #44072 is a reply to message #44071] |
Sun, 15 May 2005 09:03   |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Christopher Lee wrote:
> In article <d674k0$3dl$1@zam602.zam.kfa-juelich.de>, "Reimar Bauer"
> <R.Bauer@fz-juelich.de> wrote:
>
>
>> Dear all
>> I am searching for the function which tells idl what kind of type a
>> variable gets by it's assignment. e.g.
>> ....
>> cheers
>> Reimar
>
> Hi Reimar ,
>
> I'm not sure I understand, do you want the type of a constant value? (e.g
> 1, 2.3, 50000 ). Wouldn't SIZE or SIZE(/type) do this for you?
>
> size(1, /type) -> 2 ;INT
> size(50000, /type) -> 3 ;LONG
> size(1.0, /type) -> 4 ;FLOAT
> compile_opt idl2
> size(1,/type) -> 3 ;LONG
>
> Chris.
Hi Chris,
I look for the opposite direction. If I have a text file e.g.
[call_read]
a=1
b=50000
c=1.0
d='some text'
e=[1,2,3,4]
then I have strings and want to know which type is needed if they would be
assigned to variables.
With the read_ini() from our library* I could read this easily into a
structure using simple types. At the moment I do determine between float,
long or string. But I don't do it the same way as idl it did.
I am intereseted how idl it did and if it is implemented somewhere without
the usage of EXECUTE. For example if it is named type:
IDL> print,type('1B')
IDL> 1
IDL> print,type('1')
IDL> 2
IDL> print,type('50000')
IDL> 3
IDL> print,type('1.0')
IDL> 4
IDL> print,type('some text')
IDL> 7
IDL> print,type('[1,2,3,4]')
IDL> 2 2 2 2
One way could be to call type in a different idl session and to use the file
as input like a journal. But I don't like to do this.
*The read_ini()/write_ini will be published with the next version in
probably two months.
cheers
Reimar
--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
|
|
|