comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » sec : U Re: Ascertaining Keyword Parameters
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
sec : U Re: Ascertaining Keyword Parameters [message #30192] Wed, 10 April 2002 22:37
Andrew Cool is currently offline  Andrew Cool
Messages: 219
Registered: January 1996
Senior Member
Ted Cary wrote:
>
> Hello,
>
> Is there any way to ask an IDL function or procedure what keyword
> parameters it accepts? I'd like a function that takes the string name
> of an IDL procedure and returns a string array containing the names of
> all accepted keyword parameters--something like the "KEYWORDS_ACCEPTED"
> function below.
>
> IDL> plotKeywords = KEYWORDS_ACCEPTED('PLOT')
> IDL> PRINT, plotKeywords
> BACKGROUND CHARSIZE CHARTHICK CLIP COLOR FONT LINESTYLE MULTI NOCLIP
> NOERASE NSUM POSITION....
>
> Maybe someone with experience writing IDL system routines knows how to
> do this?
>
> Thanks.

Hi Ted,

Here's some hackware that will return the keywords for user
routines already compiled, but not for IDL system routines,
not routines using the "hidden" option to the !Compile flag.

Not pretty, but yours to play with...

Andrew


PRO Keywords_accepted, routine_name, PROC=proc, FUNC = func


; 11-Apr-2002 A.D. Cool Assuming a routine is already compiled, return
the keywords for it.
; Doesn't work for IDL system routines... ;-(
; Or for routines compiled with !Compile_opt =
hidden

print,'routine_name = ',routine_name

cmd = 'Help,Name=' + routine_name + $
',Out=KW_Text,/Rout,proc=' + String(proc) + ',func=' +
String(func)

result = EXECUTE(cmd)
If result EQ 0 Then Begin
Message,'Error in Keywords_accepted getting Help for ' +
routine_name,/INFO
RETURN
Endif

; help,Kw_text
; print,KW_text,format='(a)'

rn_len = STRLEN(routine_name)
cmd = 'kw_pos=STRPOS(kw_text(2), "' + routine_name + '")'
result = EXECUTE(cmd)
KW_pos = STRPOS(kw_text(*),routine_name)
KW_pos = WHERE(KW_pos NE -1)
If KW_pos(0) Eq -1 Then Begin
Message,'No Keywords available for ' + routine_name,/INFO
RETURN
Endif

; concatenate these lines...

KW_line = KW_text(Kw_pos(0))
Kw_line = STRCOMPRESS(KW_line)
Kw_line = STRMID(KW_line,rn_len+1,STRLEN(KW_line))
upper = WHERE(BYTE(KW_line) GE 65 AND BYTE(KW_line) LE 90)
KW_upper = STRMID(KW_line,upper(0),STRLEN(KW_line))
print,'Keywords = ',KW_upper

END


------------------------------------------------------------ ---------
Andrew D. Cool .->-.
Electromagnetics & Propagation Group `-<-'
Surveillance Systems Division Transmitted on
Defence Science & Technology Organisation 100% recycled
PO Box 1500, Salisbury electrons
South Australia 5108

Phone : 061 8 8259 5740 Fax : 061 8 8259 6673
Email : andrew.cool@dsto.defence.gov.au
------------------------------------------------------------ ---------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Where is "Pause" function?
Next Topic: Simple? problem

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:01:14 PDT 2025

Total time taken to generate the page: 0.00356 seconds