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

Home » Public Forums » archive » Re: SAVE again
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: SAVE again [message #71019] Tue, 25 May 2010 23:54 Go to next message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On May 25, 9:18 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
> On May 25, 5:45 pm, pp <pp.pente...@gmail.com> wrote:
>
>
>
>
>
>> On May 25, 9:05 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
>
>>> Is it possible to simplify this line:
>
>>> save, v1, v2, v3, v4, v5,...,v100, filename = 'xxx..sav'
>
>>> by using something like this:
>
>>> for j=1,100 do print, 'v'+strtrim(string(j),1)+','
>
>>> ... so I don't have to write down "v" a hundred times?
>
>> Possible, yes. But that is not your problem. Your code really should
>> not have 100 variables called vxxx. It is a nightmare to read and to
>> edit.
>
>> Why don't you put all that stuff into a single array?
>
> Hi pp,
>
> Yes, I know... this is a bad example. I don't actually have 100
> variables called vxxx. Just wanted to know if there is a way to pass
> the variable names to be saved other than typing each name and passing
> them as parameters on the line. I think CMSAVE will do it... thanks,
> Craig!

You can automate actions with multiple variations of the same filename
by using EXECUTE. Thus, in this example, you would want to do
something like:
vars = strjoin('v'+strtrim(indgen(100)+1,1),',')
fname = string(39B)+'xxx.sav'+string(39B)
status = EXECUTE('save, '+vars+', filename='+fname)
Re: SAVE again [message #71021 is a reply to message #71019] Tue, 25 May 2010 18:18 Go to previous messageGo to next message
fgg is currently offline  fgg
Messages: 67
Registered: April 2010
Member
On May 25, 5:45 pm, pp <pp.pente...@gmail.com> wrote:
> On May 25, 9:05 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
>
>> Is it possible to simplify this line:
>
>> save, v1, v2, v3, v4, v5,...,v100, filename = 'xxx..sav'
>
>> by using something like this:
>
>> for j=1,100 do print, 'v'+strtrim(string(j),1)+','
>
>> ... so I don't have to write down "v" a hundred times?
>
> Possible, yes. But that is not your problem. Your code really should
> not have 100 variables called vxxx. It is a nightmare to read and to
> edit.
>
> Why don't you put all that stuff into a single array?

Hi pp,

Yes, I know... this is a bad example. I don't actually have 100
variables called vxxx. Just wanted to know if there is a way to pass
the variable names to be saved other than typing each name and passing
them as parameters on the line. I think CMSAVE will do it... thanks,
Craig!
Re: SAVE again [message #71022 is a reply to message #71021] Tue, 25 May 2010 17:45 Go to previous messageGo to next message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On May 25, 9:05 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
> Is it possible to simplify this line:
>
> save, v1, v2, v3, v4, v5,...,v100, filename = 'xxx..sav'
>
> by using something like this:
>
> for j=1,100 do print, 'v'+strtrim(string(j),1)+','
>
> ... so I don't have to write down "v" a hundred times?

Possible, yes. But that is not your problem. Your code really should
not have 100 variables called vxxx. It is a nightmare to read and to
edit.

Why don't you put all that stuff into a single array?
Re: SAVE again [message #71024 is a reply to message #71022] Tue, 25 May 2010 17:35 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On May 25, 8:05 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
> Hello,
>
> Is it possible to simplify this line:
>
> save, v1, v2, v3, v4, v5,...,v100, filename = 'xxx..sav'
>
> by using something like this:
>
> for j=1,100 do print, 'v'+strtrim(string(j),1)+','
>
> ... so I don't have to write down "v" a hundred times?

You might want to try this library,
http://www.physics.wisc.edu/~craigm/idl/cmsave.html
which can programmatically create SAVE files.

Craig
Re: SAVE again [message #71113 is a reply to message #71022] Wed, 26 May 2010 01:45 Go to previous message
Carsten Lechte is currently offline  Carsten Lechte
Messages: 124
Registered: August 2006
Senior Member
pp wrote:
> Why don't you put all that stuff into a single array?

The original poster did not give any specifics, but the usual
way a beginning IDL programmer end up with lots of variables
is when when he has arrays of differents data types and/or
different sizes. One way of imposing some kind of structure
on them is to put the variables into a structure. This is a
good way to group together a set of variables that each describe
a different aspect of some object (like name, position, color...)
Then you have the dilemma of using an array of structs or a
struct of arrays.

The other way is using an array of pointers to the various arrays,
like alldata = PTRARR( numarr), then alldata[0] = PTR_NEW( v1) etc.
I use this a lot when I have a list of data files to read, and the
data arrays in the files do not all have the same dimensions.


chl
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: rotate tickname and titles
Next Topic: Re: Matching data in different time resolution

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

Current Time: Wed Oct 08 15:22:24 PDT 2025

Total time taken to generate the page: 0.00596 seconds