Re: Pri [message #69900 is a reply to message #68672] |
Thu, 25 February 2010 12:12   |
JDS
Messages: 94 Registered: March 2009
|
Member |
|
|
On Feb 25, 9:53 am, Lasse Clausen <l...@lbnc.de> wrote:
> Hi there,
>
> I have written a little routine that prints out the usage of routines/
> procedures written in IDL on the command line. Like so:
>
> IDL> pri, 'reverse'
> +---+
> Function REVERSE
> Usage:
> Result = REVERSE(A, SUBSCRIPTIN, OVERWRITE=OVERWRITE)
> Source:
> /usr/local/itt/idl/lib/reverse.pro
> +---+
Since IDLWAVE does this as well (in context with C-c ?), but also
includes system routines (even when not available as .pro files), I
thought I'd mention how it does so. Since around IDL 6.2, ITT has
distributed with IDL an XML file which describes all of their
routines, system variables, object classes, etc.: idl/help/
idl_catalog.xml. It also gives detailed information on calling
syntax, keywords, etc. Here's some simple code to parse this XML file
to print the calling syntax of all the system routines for the
currently running version of IDL:
dom=obj_new('IDLffXMLDOMDocument',VALIDATION_MODE=0, $
FILENAME=filepath('idl_catalog.xml',SUBDIR='help'))
catalog=((dom->GetFirstChild())->GetNextSibling())->GetNextSibling()
routines=catalog->GetElementsByTagName('ROUTINE')
for i=0,routines->GetLength()-1 do begin
routine=routines->Item(i)
name=routine->GetAttribute('name')
syns=routine->GetElementsByTagName('SYNTAX')
print,name,':'
for j=0,syns->GetLength()-1 do $
print,' Syntax: ',(syns->Item(j))->GetAttribute('name')
endfor
obj_destroy,dom
A better version would gather the keywords as well (as IDLWAVE does)
and place them in the syntax. Then perhaps tuck away a pair of string
arrays into a common variable: sorted routine name, concatenated
calling syntax. This could be used to look-up syntax (either as first
priority, or second).
Beware of ALIAS_TO entries, which point to aliases for the actual
ROUTINE block, and could obviously be worked around. You could also
consider grabbing the CLASS elements, which contain METHOD children
with their own syntax, etc. Might be very useful to have an interface
to this on the command line.
JD
P.S. Is there a reason a->b()->c doesn't work in IDL? I'd have
thought `->' was left to right associative?
|
|
|