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

Home » Public Forums » archive » Re: Variable undefined after while-cycle?
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: Variable undefined after while-cycle? [message #26659] Thu, 20 September 2001 00:19
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Craig Markwardt wrote:
>
> David Fanning <david@dfanning.com> writes:
>
>> Reimar Bauer (r.bauer@fz-juelich.de) writes:
>>
>>> you should use () only for functions
>>> [] should be used for arrays.
>>
>> Please, let's not get started on proper programming
>> technique.
>
> And, as far as I'm concerned, round parentheses are accepted by IDL by
> default for array indexing, so they must be correct :-) (as are the
> square brackets too of course).
>
> This same wisdom can be found in the ancient text of _EXTRAmasutra,
> whose IDL-ku is almost a lost form of expression today. The guru says
> it in an obscure way, but the meaning is clear:
>
> index, NOT careless
> to, slice AND dice (arrays), a
> round (blade) = sharper
>
> I still do not yet use a "square blade" for my array indexing, it is
> too dull. :-)


Dear Craig,

a lot of my old code is using () too. But [] gets some code
better readable. So everytime I add a new keyword or something else to
an old script I correct the () into [].

In the past I got some problems with funtions named as arrays both
are with (). This problem is solved by using [] for arrays.
For me this is a good idea.


How did you switch of this option:
COMPILE_OPT STRICTARR

I have no idea.


regards
Reimar









>
> Craig
>
> [ For those uninitiated in IDL-ku, it reads like a 5-7-5 syllable
> haiku, but is a compileable IDL program. The equals sign "=" can
> either be silent or the single syllable "is". ]
>
> --
> ------------------------------------------------------------ --------------
> Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
> Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
> ------------------------------------------------------------ --------------




--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======

read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
Re: Variable undefined after while-cycle? [message #26667 is a reply to message #26659] Wed, 19 September 2001 18:11 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
David Fanning <david@dfanning.com> writes:


> Reimar Bauer (r.bauer@fz-juelich.de) writes:
>
>> you should use () only for functions
>> [] should be used for arrays.
>
> Please, let's not get started on proper programming
> technique.

And, as far as I'm concerned, round parentheses are accepted by IDL by
default for array indexing, so they must be correct :-) (as are the
square brackets too of course).

This same wisdom can be found in the ancient text of _EXTRAmasutra,
whose IDL-ku is almost a lost form of expression today. The guru says
it in an obscure way, but the meaning is clear:

index, NOT careless
to, slice AND dice (arrays), a
round (blade) = sharper

I still do not yet use a "square blade" for my array indexing, it is
too dull. :-)

Craig

[ For those uninitiated in IDL-ku, it reads like a 5-7-5 syllable
haiku, but is a compileable IDL program. The equals sign "=" can
either be silent or the single syllable "is". ]

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Variable undefined after while-cycle? [message #26679 is a reply to message #26667] Wed, 19 September 2001 09:28 Go to previous message
Martin Downing is currently offline  Martin Downing
Messages: 136
Registered: September 1998
Senior Member
I think Pavels solution will always be true as Lasttime is now defined
identical to this time (ie mstime)
try these changes (marked by ;**)#
cheers
Martin

;** add
Lasttime = -1 ; dummy value which should always be different from mstime
;**
while not EOF(lun) do begin
readf, lun, line
line=strjoin(strsplit(line,'"',/extract),/single)
;** delete Lastline here
values=strsplit(line,',',/extract)
msdate=double(values(0))
mstime=double(values(1))
;** modify below so that you dont detect the first loop as changed
if (Lasttime ne -1) and (Lasttime ne mstime) then begin
;**
print,'', Lasttime, mstime, ' Zeiten sind ungleich!'
Zeitpunkt=mstime2sqlts(msdate,mstime)
insertstr='INSERT INTO ' + table + ' VALUES ("'
+sqlts2datetimestr(Zeitpunkt) + '"'
for i=2,(n_elements(fields)-1) do insertstr=insertstr + ', ' + values(i)
insertstr=insertstr+ ' ) ;'
;;;XX
;dbobj->ExecuteSQL,insertstr
endif else begin
print,'', Lasttime, mstime, ' Zeiten sind gleich!'
endelse
;**
Lasttime = mstime ; now set to mstime ready for next loop
;**
endwhile


--
----------------------------------------
Martin Downing,
Clinical Research Physicist,
Orthopaedic RSA Research Centre,
Woodend Hospital, Aberdeen, AB15 6LS.
Tel. 01224 556055 / 07903901612
Fax. 01224 556662

m.downing@abdn.ac.uk

"Pavel A. Romashkin" <pavel.romashkin@noaa.gov> wrote in message
news:3BA8B32E.9BE43C7B@noaa.gov...
> Olaf Stetzer wrote:
>>
>> while not EOF(lun) do begin
>> readf, lun, line
>> line=strjoin(strsplit(line,'"',/extract),/single)
>> Lasttime=double(values(1))
>
> From the code snippet I see, VALUES[0] is not defined yet. Switch the
> line above with the next line that defines VALUES.
>
>> values=strsplit(line,',',/extract)
>> msdate=double(values(0))
>> mstime=double(values(1))
>> if (Lasttime ne mstime) then begin
>> print,'', Lasttime, mstime, ' Zeiten sind ungleich!'
>> Zeitpunkt=mstime2sqlts(msdate,mstime)
>> insertstr='INSERT INTO ' + table + ' VALUES ("' +
>> sqlts2datetimestr(Zeitpunkt) + '"'
> ...
Re: Variable undefined after while-cycle? [message #26680 is a reply to message #26679] Wed, 19 September 2001 09:16 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Reimar Bauer (r.bauer@fz-juelich.de) writes:

> you should use () only for functions
> [] should be used for arrays.

Please, let's not get started on proper programming
technique.

It was my "pleasure" yesterday to work with some IDL programs
distributed with TRMM data. Yikes!

Let's just say there are probably a few more people
out there who ought to help Liam and me get rich by
buying an IDL programming book. :-)

Cheers,

David

P.S. In the TRMM folks defense, these programs were
fairly old by software standards. But still, let's
try to avoid writing programs that work only on the
computer the programmer happens to have on his/her
desk. Long live device/color/computer independence!!

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Variable undefined after while-cycle? [message #26681 is a reply to message #26680] Wed, 19 September 2001 08:46 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Olaf Stetzer wrote:
>
> Hello,
>
> I have a strange problem which may be related to the
> way IDL frees varaibles in/after subroutines. In the
> following example I want to compare a value with the
> one from the last while-cycle, however the Variable
> to store the Value for the next cycle (Lasttime)
> seems to be empty even at the end of the cycle
> (at point ;;;XX). When I define the Variable Lasttime
> before the while not EOF.... then the behaviour is
> still the same, the comparison (Lasttime ne mstime)
> is always true, even if it should not!
>
> Thanks,
>
> Olaf
>
> ----------------
> while not EOF(lun) do begin
> readf, lun, line
> line=strjoin(strsplit(line,'"',/extract),/single)
> Lasttime=double(values(1))
> values=strsplit(line,',',/extract)
> msdate=double(values(0))
> mstime=double(values(1))
> if (Lasttime ne mstime) then begin
> print,'', Lasttime, mstime, ' Zeiten sind ungleich!'
> Zeitpunkt=mstime2sqlts(msdate,mstime)
> insertstr='INSERT INTO ' + table + ' VALUES ("' +
> sqlts2datetimestr(Zeitpunkt) + '"'
> for i=2,(n_elements(fields)-1) do insertstr=insertstr + ', ' +
> values(i)
> insertstr=insertstr+ ' ) ;'
> ;;;XX
> ;dbobj->ExecuteSQL,insertstr
> endif else begin
> print,'', Lasttime, mstime, ' Zeiten sind gleich!'
> endelse
> endwhile
>

Dear Olaf,

you should use () only for functions
[] should be used for arrays.


I aggree to Pavels solution.


regards

Reimar



--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======

read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
Re: Variable undefined after while-cycle? [message #26682 is a reply to message #26681] Wed, 19 September 2001 08:01 Go to previous message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
Olaf Stetzer wrote:
>
> while not EOF(lun) do begin
> readf, lun, line
> line=strjoin(strsplit(line,'"',/extract),/single)
> Lasttime=double(values(1))

From the code snippet I see, VALUES[0] is not defined yet. Switch the
line above with the next line that defines VALUES.

> values=strsplit(line,',',/extract)
> msdate=double(values(0))
> mstime=double(values(1))
> if (Lasttime ne mstime) then begin
> print,'', Lasttime, mstime, ' Zeiten sind ungleich!'
> Zeitpunkt=mstime2sqlts(msdate,mstime)
> insertstr='INSERT INTO ' + table + ' VALUES ("' +
> sqlts2datetimestr(Zeitpunkt) + '"'
...
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Way to determine big/little endian?
Next Topic: Re: Arrow command/ velovect plot resolution

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

Current Time: Wed Oct 08 15:28:21 PDT 2025

Total time taken to generate the page: 0.00644 seconds