[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: something like perl's 'require 5.4'



JD Smith <jdsmith@astro.cornell.edu> writes:

> Craig Markwardt wrote:
> > 
> > Vapuser <vapuser@catspaw.jpl.nasa.gov> writes:
> > > Hi all.
> > >
> > >   I'm looking for something that check the version of the current IDL
> > >   session against an input version, like perl's 'require 5.4'
> > >   semantics and I *thought* I saw someone mention using something very
> > >   much like this.
> > >
> > >   Does anyone know of such a thing or was I just hallucinating?
> > 
> > Extending on JD's answer with two more possibilities:
> > 
> > if        !version.release  LT '5.4' then message, 'ERROR'
> > if double(!version.release) LT  5.4  then message, 'ERROR'
> > 
> > The first comparison is a string compare, while the second one is a
> > numeric compare.  There is a slight difference, but in practice they
> > are identical, and they also both handle the case of 5.4.1, etc.  The
> > former will handle 5.4.1a, but I think it's rare.  I always use the
> > latter.
> 
> Hmmm...
> 
> IDL> print,double('5.4') lt double ('5.4.1')
>    0
> IDL>print,double('5.4') eq double ('5.4.1')
>    1
> 
> Hopefully RSI won't try to pull the latter on us.
> 
> On the other hand, your string method looks good.  The best counter
> example I could come up with is:
> 
> IDL> print,'5.5a' lt '5.5B'
>    0
> 
> Not too likely.  I think I'll adopt the string version.  
> 
> Thanks,
> 
> JD

  How about:

  version=strupcase(strjoin(strsplit(!version.release,'[.-_]',/extract),""))
  input_version=strupcase(strjoin(strsplit(desired_release,'[.-_]',/extract),""))
  if version lt input_version then 'eeek'

  Clearly `desired_release' would have to be input as a string.

  Of couse, this method 'requires' IDL 5.3 (IIRC), to get the regular
  expression semantics of strsplit. The other question is will RSI use
  any separator in version designations besides these three?

whd
-- 
William Daffer: 818-354-0161: William.Daffer@jpl.nasa.gov