[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: David: for your book ?
Craig Markwardt wrote:
>
> Martin Schultz <martin.schultz@dkrz.de> writes:
> > As an aside, I recently found another problem in terms of backward
> > compability (I am
> > sure something similar was already mentioned in this newsgroup, but this
> > was the first
> > time I had this problem):
> > I tried to write a routine that takes advantage of the new StrMatch
> > and StRegex
> > functions in 5.3. In order to ensure backward compatibility, I enclosed
> > these function calls
> > with
> > IF !Version.Release GE 5.3 THEN BEGIN
> > ENDIF
> >
> > However, a colleague tells me: no chance! The program will report a
> > syntax error when run in
> > IDL 5.2! So, the problem is that IDL looks for a function of this name
> > during compile stage
> > and doesn't care if it will ever be used.
> ...
>
> There is a way to do this without defining an external function, by
> using FORWARD_FUNCTION properly:
>
> FORWARD_FUNCTION stregex, strmatch
> IF !Version.Release GE 5.3 THEN BEGIN
> foo = stregex(bar)
> sm = strmatch(eg)
> ENDIF
>
> This will make sure that IDL will always recognize strmatch & stregex
> as functions during the compilation stage, and there will be no syntax
> errors in any IDL version. It is harmless in IDL 5.3. If you really
> want the warning message, then by all means go ahead and make your own
> strmatch definitions et al.
>
> Have fun,
> Craig
>
> --
Don't write it yourself
Take the strmatch routine from the deutsch library
http://www.astro.washington.edu/deutsch/idl/htmlhelp/slibrary24.html
Reimar