Converting to [] array subscripts [message #9195] |
Sun, 08 June 1997 00:00 |
Wayne Landsman
Messages: 117 Registered: January 1997
|
Senior Member |
|
|
I like the use of square brackets for array subscripts in IDL V5.0 -- it
forever banishes the variable/function ambiguity, and makes the code
read better. To quickly convert old code to use square bracket
subscripts, I've written a procedure IDLV4_TO_V5 available with
supporting procedures in ftp://idlastro.gsfc.nasa.gov/landsman/v5/
which will change all the subscripted parentheses in a procedure to
square brackets (and leave everything else unchanged.) The intrinsic
ROUTINE_INFO() function is used to determine the names of valid
variables, and thus determine which parenthesis should be altered.
IDLV4_TO_V5 has the following limitations (plus I am sure others which I
don't yet know about):
1. It doesn't work on main programs (i.e. without a 'pro' or
'function' definition)
2. It might get confused if parentheses are placed in a string,
e.g. "printf,3,')alpha('"
3. It only parses one line at a time, and so can get confused by
continuation lines.
Number 3 seems the most serious limitation, but in fact most users
would not break up an array subscript into separate lines, so in my case
IDLV4_TO_V5 seemed to work for ~99% of the ~400 procedures I tried it
on.
One quirk I found in V5.0 is that for a structure x, x.tag[3] is
legal, but x.[3] is not -- although x.(3) is!
Other caveats - I've only tested it on a Unix system (Solaris 2.5),
and the code is pretty clunky right now. I welcome suggestions for
improvement.
--Wayne Landsman landsman@mpb.gsfc.nasa.gov
|
|
|