Re: Variable undefined after while-cycle? [message #26681 is a reply to message #26680] |
Wed, 19 September 2001 08:46   |
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
|
|
|