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

Home » Public Forums » archive » Declaring large vectors in IDL
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: Declaring large vectors in IDL [message #70615 is a reply to message #70537] Wed, 21 April 2010 12:15 Go to previous messageGo to previous message
fgg is currently offline  fgg
Messages: 67
Registered: April 2010
Member
> Great! I guess Scope_VarFetch is the function I was looking for. This
> solves my problem:
>
> pro test
> heads=['a', 'b', 'c']
> data = ['1 2 3', '4 5 6', '7 8 9']
> for i=0,2 do (Scope_VarFetch(heads[i], LEVEL=1, /ENTER)) =
> strsplit(data[i],/extract)
> end
>
> Thanks, David.


Ok, now I have "a", "b", and "c" saved to the main IDL level. Assuming
that they don't have the same number of elements, what is the easiest
way to write them out to a *.csv file? Here are other questions
related to this script I'm working on. Any help would be appreciated!


1) How can I summarize these two lines in just one line of code?

if (line[0] eq 'i_rng_wf' and n_elements(line) ne 4002) then message,
'The # of samples per shot is not valid.'
if (line[0] eq 'i_rng_wf' and n_elements(line) ne 10882) then message,
'The # of samples per shot is not valid.'

...I thought using OR would do the trick, but I guess I'm missing
something here:

if (line[0] eq 'i_rng_wf' and n_elements(line) ne (4002 or 10882))
then message, ...


2) When reading a text file like this at once:

=xxx
id = 1
a = 3 3 0
b = 1 0 5
c = 7 9 1
=xxx
id = 2
a = 2 9 1
b = 7 5 4
c = 9 3 7

...using file_lines and a string array:

infile = '/path/filename'
n = file_lines(infile)
data = strarr(n)
openr, inunit, infile, /get_lun
readf, inunit, data

How could I use the "=xxx" lines to break the data into multiple
arrays? Or maybe just ignore the "=xxx" lines and relate, somehow,
each variable (a, b, and c in the example) to a given "id"?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Problem with variable declaration
Next Topic: Rounding off

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

Current Time: Fri Oct 10 23:16:42 PDT 2025

Total time taken to generate the page: 0.15909 seconds