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

Home » Public Forums » archive » Save file creation rules of the road
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
Save file creation rules of the road [message #69827] Thu, 18 February 2010 03:30 Go to next message
Rob[2] is currently offline  Rob[2]
Messages: 11
Registered: May 2007
Junior Member
Dear save file gurus,

I'm trying to create a distributable IDL save file via IDLDE > Project
> "Build Project". A save file was created without error -- some
initial complaints were issued, then automatically resolved. I then
restored this save file in a new IDL cli session. All expected
functions and procedures were listed, via "restore, /verbose" and
"help"; see below. However, an attempt to run one of the restored
procedures yielded the annoying "Variable is undefined:
SPIDR_ASCII_GET_META.... EXCEPTION..." I've experienced this before
and the hack I employed wasn't pretty. It involved compiling
(via .compile) all functions and procedures I thought I needed and
creating a save file somewhat manually, then a sacrificial lamb and a
kabuki dance. Thus, I suppose I've never really learned how to create
a proper save file with just the functionality I need. Can someone
point me in the right direction?

Debug follows:

Noting the below "help" after restore in new session, you can see for
yourself that "SPIDR_ASCII_GET_META" is defined:

Compiled Procedures:
$MAIN$ BAR_PLOT CALDAT CHECK_INIT DOC_LIBRARY
LEGEND LOADCT LOGGER LOG_DEBUG LOG_ERROR
LOG_FATAL LOG_INFO LOG_WARN MG_OPEN_URL
NGDC_BOILER PRINT_LOG_MESSAGE RESOLVE_ALL
SPIDR_CLIENT SPIDR_CRIB SPIDR_CRIB_IONO_7_DAYS
SPIDR_CRIB_IONO_EVENT SPIDR_CRIB_SENSOR_FUSION

Compiled Functions:

FGDC_TO_SIMPLE_STRUCT FILEPATH IS_STRUCT
IS_STRUCTURE JDAY_TO_TIME_8601
JDAY_TO_TIME_ARRAY JDAY_TO_UNIX_TIME JULDAY
LABEL_DATE MEAN MM MOMENT
SPIDR_ASCII_GET_META
SPIDR_ASCII_TO_STRUCTURE SPIDR_GET_DATA
SPIDR_GET_METADATA
STDDEV STRSPLIT TEST_SPIDR_ASCII_TO_STRUCTURE
TEST_SPIDR_GET_DATA TEST_SPIDR_GET_METADATA
TIME_8601_TO_ARRAY TIME_ARRAY_TO_8601 UNIQ

IDL> print, TEST_SPIDR_ASCII_TO_STRUCTURE()
% Variable is undefined: SPIDR_ASCII_GET_META.
% Execution halted at: SPIDR_ASCII_TO_STRUCTURE
% TEST_SPIDR_ASCII_TO_STRUCTURE
% $MAIN$
Re: SAVE [message #70873 is a reply to message #69827] Fri, 14 May 2010 06:53 Go to previous messageGo to next message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
On May 13, 5:21 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
>> Isn't there an international convention, signed in
>> Geneva, against using such cruel practices in computer
>> programming code? I'd be very very careful with that...
>
>> Ciao,
>> Paolo
>
> Is there? Cool... but I'm still waiting for the part where you provide
> an acceptable alternative. Isn't that the idea?

The acceptable alternative of using scope_varfetch to move data
up and down the hierarchy of your programs is to use the
arguments and keywords of your routines.

And regarding your original question, I did not quite understand
what you were trying to accomplish - so I am sorry I could not offer
any useful advice there.

Ciao,
Paolo
Re: SAVE [message #70877 is a reply to message #69827] Thu, 13 May 2010 17:43 Go to previous messageGo to next message
Aram Panasenco is currently offline  Aram Panasenco
Messages: 41
Registered: April 2010
Member
fgg wrote:
>> Isn't there an international convention, signed in
>> Geneva, against using such cruel practices in computer
>> programming code? I'd be very very careful with that...
>>
>> Ciao,
>> Paolo
>>
>
> Is there? Cool... but I'm still waiting for the part where you provide
> an acceptable alternative. Isn't that the idea?

If I had to _guess_ what you are trying to do, I'd say that you want to
save all variables in the current IDL session to a save file. That is
done rather simply:

save, /ALL, filename='.../.sav'

~Aram Panasenco
Re: SAVE [message #70878 is a reply to message #69827] Thu, 13 May 2010 17:41 Go to previous messageGo to next message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On May 13, 5:21 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
>> Isn't there an international convention, signed in
>> Geneva, against using such cruel practices in computer
>> programming code? I'd be very very careful with that...
>
>> Ciao,
>> Paolo
>
> Is there? Cool... but I'm still waiting for the part where you provide
> an acceptable alternative. Isn't that the idea?

Why don't you just SAVE your variables, then RESTORE them at the main
level?
Re: SAVE [message #70880 is a reply to message #69827] Thu, 13 May 2010 14:29 Go to previous messageGo to next message
Aram Panasenco is currently offline  Aram Panasenco
Messages: 41
Registered: April 2010
Member
fgg wrote:
> Hi there,
>
> I'm running a procedure that has lines in it such as:
>
> (Scope_VarFetch('data', LEVEL=1, /ENTER)) = 1
>
> ... that are used to save variables to the main IDL level. I'd like to
> add a line at the end of this procedure to make it save all variables
> that were created in a *.sav file. Something like this:
>
> save, /variables, filename= '/Users/xxx/Desktop/example.sav'
>
> ... but it's not working. I'm getting in the *.sav file all other
> variables defined in the procedure, but the ones created using
> Scope_VarFetch. Any suggestions?
>
> PS: if I run the procedure first (without the save line in it) and
> then type the save line at the IDL prompt I get exactly what I want.
> Just wanted to know if it's possible to automate this process.
>
> Thank you!

Hello fgg,

scope_varfetch is a highly dangerous routine that you should only use if
there is absolutely no other alternative to implementing something
crucial (and there almost always is). Seeing as you are new, we can't
give you advice on how to use scope_varfetch because it will make your
program harder to write, more prone to errors, and, most importantly,
using scope_varfetch can interfere with other IDL programs, making your
program unusable (by you and others). Instead, can you tell us in more
detail what exactly you are trying to do so that we can show you a
better way to accomplish it. What tasks does your procedure aim to do?

~Aram Panasenco
Re: SAVE [message #70881 is a reply to message #69827] Thu, 13 May 2010 14:25 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
fgg writes:

> Is there? Cool... but I'm still waiting for the part where you provide
> an acceptable alternative. Isn't that the idea?

It occurs to me that if you can write the variables to the
main IDL level, you ought to be able to write them to
a SAVE file. :-)

If they have disappeared on you when you moved them to
the main level, save them before you do that.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
Re: SAVE [message #70882 is a reply to message #69827] Thu, 13 May 2010 14:21 Go to previous messageGo to next message
fgg is currently offline  fgg
Messages: 67
Registered: April 2010
Member
> Isn't there an international convention, signed in
> Geneva, against using such cruel practices in computer
> programming code? I'd be very very careful with that...
>
> Ciao,
> Paolo
>

Is there? Cool... but I'm still waiting for the part where you provide
an acceptable alternative. Isn't that the idea?
Re: SAVE [message #70884 is a reply to message #69827] Thu, 13 May 2010 13:57 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paolo writes:

> Isn't there an international convention, signed in
> Geneva, against using such cruel practices in computer
> programming code? I'd be very very careful with that...

Yeah, people have been arrested for aiding and abetting
when they have spelled out how to do things like this! :-(

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
Re: SAVE [message #70885 is a reply to message #69827] Thu, 13 May 2010 13:53 Go to previous messageGo to next message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
On May 13, 4:05 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
> Hi there,
>
> I'm running a procedure that has lines in it such as:
>
> (Scope_VarFetch('data', LEVEL=1, /ENTER)) = 1

Isn't there an international convention, signed in
Geneva, against using such cruel practices in computer
programming code? I'd be very very careful with that...

Ciao,
Paolo


>
> ... that are used to save variables to the main IDL level. I'd like to
> add a line at the end of this procedure to make it save all variables
> that were created in a *.sav file. Something like this:
>
> save, /variables, filename= '/Users/xxx/Desktop/example.sav'
>
> ... but it's not working. I'm getting in the *.sav file all other
> variables defined in the procedure, but the ones created using
> Scope_VarFetch. Any suggestions?
>
> PS: if I run the procedure first (without the save line in it) and
> then type the save line at the IDL prompt I get exactly what I want.
> Just wanted to know if it's possible to automate this process.
>
> Thank you!
Re: SAVE [message #71015 is a reply to message #70873] Fri, 14 May 2010 13:22 Go to previous message
fgg is currently offline  fgg
Messages: 67
Registered: April 2010
Member
Thanks a lot for the constructive comments! I was using SCOPE_VARFETCH
simply to export the variables to the main level... but I'm now
convinced that this is not a good practice. One of the suggestions I
got was to include parameters in my procedure, define the variables
within the procedure, and then call it specifying the parameters
similarly on the command line. Something like this:

pro xxx, a=a, b=b, c=c


This would add the variables of interest (a, b, and c) in main just
like SCOPE_VARFETCH does. I guess that's the usual way of doing this
and I would probably not end in jail =)... so, here we go.

Thanks again,
Fabio
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: coping with a slow license server
Next Topic: Re: Breaking files

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

Current Time: Wed Oct 08 15:35:12 PDT 2025

Total time taken to generate the page: 0.00825 seconds