[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:
> > Hi,
> >
> >    Testing IDL's capabilities is always dangerous: you might get more
> > than you ask for!
> >
> > What would you expect to get out of the following:
> >
> > test = [ 'dir1/', 'directory2/', 'another_directory/' ]
> > print,strmid(test,0,strlen(test)-1)
> Hmm, I got an error message!
> IDL> test = [ 'dir1/', 'directory2/', 'another_directory/' ]
> IDL> print,strmid(test,0,strlen(test)-1)
> % STRMID: Expression must be a scalar in this context: <LONG      Array[3]>.
> % Execution halted at:  $MAIN$
> IDL> print, !version
> { alpha OSF unix 5.2 Oct 30 1998}
> Is this something new in IDL 5.3?

Apparently so! What I get as a result is a 3x3 matrix containing in the
first column 
all directory namews truncated to a length of 4, in the second column
10, and in the 
third column StrLen(test[2]-1). But I am glad you point this out. 

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
    IF !Version.Release GE 5.3 THEN BEGIN

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. Only help is to write two
little dummy functions 
named stregex.pro and strmatch.pro which do nothing but print a warning
message. And so I
did. Works nicely, and you don't even have to test for the release
number because these two
functions are internal in 5.3 and hence they are discovered before
anything on disk can be

Just a little bedtime story ;-)


[[ Dr. Martin Schultz   Max-Planck-Institut fuer Meteorologie    [[
[[                      Bundesstr. 55, 20146 Hamburg             [[
[[                      phone: +49 40 41173-308                  [[
[[                      fax:   +49 40 41173-298                  [[
[[ martin.schultz@dkrz.de                                        [[