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

Home » Public Forums » archive » Re: what to make of read_interfile.pro ?
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: what to make of read_interfile.pro ? [message #63128] Wed, 29 October 2008 07:40 Go to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Mike wrote:
> In the code, there is a structure that handles image headers. Each
> header has widget_base associated with it and the uvalue for that that
> base is used to store the header data value. There is another
> widget_base uvalue that is used to handle valid choices. This is in
> an entirely non-gui procedure by the way. At the end of the
> procedure, there is a loop that "widget_control, /destroy"s the
> widget_bases.
>
> Anyone have an idea of why the author might have made that choice?
> Were there no pointers in 1993? Maybe the original author
> (Goldstein) just wanted to toy with us here in the future?

Pointers were introduced in v5 - and back in '93 I think something like v3.6 might have
been current. But, didn't v3 and such have those things called "handles" that were sorta
like pointers? Anyway....

> Anyway, out of respect/fear/queasiness, I think I may let this
> procedure rest in peace and write a header cleaner/fixer to stick in
> between reading the header and interpreting it.

I think respect is warranted - the author came up with a clever solution when no other
methodology was available. But, regardless, read thee some books/articles on unit testing
and refactoring techniques and you should be able to fix the code without any vestiges of
fear and/or queasiness -- assuming, of course, your boss doesn't mind (or know :o)

cheers,

paulv
Re: what to make of read_interfile.pro ? [message #63130 is a reply to message #63128] Wed, 29 October 2008 07:37 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mike writes:

> In the code, there is a structure that handles image headers. Each
> header has widget_base associated with it and the uvalue for that that
> base is used to store the header data value. There is another
> widget_base uvalue that is used to handle valid choices. This is in
> an entirely non-gui procedure by the way. At the end of the
> procedure, there is a loop that "widget_control, /destroy"s the
> widget_bases.
>
> Anyone have an idea of why the author might have made that choice?
> Were there no pointers in 1993? Maybe the original author
> (Goldstein) just wanted to toy with us here in the future?
>
> Anyway, out of respect/fear/queasiness, I think I may let this
> procedure rest in peace and write a header cleaner/fixer to stick in
> between reading the header and interpreting it.

Ah, fond memories... :-)

Yes, before pointers there were "handles" in IDL, and before
handles, there were user values of unrealized top-level base
widgets. I can't remember now if I got this idea from Josh,
or he got it from me. I probably got it from him, because
he was an amazing programmer. But I know I was the one who
started advertising it. And I remember David Stern coming
to me one time after reading about "Using Pointers in IDL"
on one of my IDL course brochures to find out just what the
hell I was teaching people out there. The rest is history. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: what to make of read_interfile.pro ? [message #63255 is a reply to message #63128] Wed, 29 October 2008 17:41 Go to previous message
Robbie is currently offline  Robbie
Messages: 165
Registered: February 2006
Senior Member
I did come up with an incredibly simplistic way to read a "flat"
interfile header.
I just use keywords to represent each entry.

; Example:
; interfile_readkey, '2001cntrate_13.s.hdr', STUDY_DATE_DD_MM_YRYR=a
pro interfile_readkey, filename, _REF_EXTRA=ex
openr, lun, filename, /GET_LUN
line = ""
while (~ EOF(lun)) do begin
readf, lun, line
if ((line ne '') && (STRMID(Line,0,1) ne ';')) then begin
if (STRMID(Line,0,1) eq '!') then line = STRMID(Line,1)
if (STRMID(Line,0,1) eq '%') then line = STRMID(Line,
1)
KeyEnd = STRPOS(Line, ":=")
if (KeyEnd ge 0) then begin
count = 0l
Kwd = strjoin(strsplit(strupcase(strtrim(stRMID(Line,
0,KeyEnd),2)),' [],=()/:',/EXTRACT),'_')
; print, kwd
if (n_elements(ex) gt 0) then $
inds = where(kwd eq ex,count)
if (count gt 0) then $
(SCOPE_VARFETCH(kwd, /REF_EXTRA)) = strtrim(stRMID(Line,
KeyEnd+2),2)
endif
endif
endwhile
free_lun, lun
end
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: array dimension change
Next Topic: About warp image on ENVI's pts file

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

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

Total time taken to generate the page: 0.00627 seconds