[Object IDL] self-documenting objects ... [message #12389] |
Fri, 31 July 1998 00:00  |
dEdmundson
Messages: 23 Registered: February 1998
|
Junior Member |
|
|
I have created a number of potentially useful objects that I wish
to share with others. Of course I have documented the code and
written a nice comment header but it would be nice to access help
online. Thus, I have adopted the convention of coding a "help"
method procedure for every object I write, viz.
myobj = obj_new('myobject')
myobj -> help
Rather than having to duplicate documentation in this method
*and* the code header, can I not simply display the source
header to the user? This approach has the benefit of encouraging
the IDL programmer to write well-documented code headers.
Comments on this convention?
Question: how can I locate the source file assuming that
I know the file name (myobject__define.pro) and that it
is located in the IDL_PATH? (IDL's filepath procedure
gives incorrect info for user written routines.)
Any help is much appreciated.
Cheers,
Darran.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
|
|
|
Re: [Object IDL] self-documenting objects ... [message #12445 is a reply to message #12389] |
Wed, 05 August 1998 00:00   |
darran
Messages: 3 Registered: August 1998
|
Junior Member |
|
|
Here is the germ of a method to include with your object
definitions:
pro myclass::help, extra=_ex
r = routine_info('MYCLASS__DEFINE', /source)
openr, source, r.path, /get_lun
s = ''
repeat begin
print, strmid(s,1)
readf, source, s
endrep until strmid(s,0,1) ne ';' or eof(source)
free_lun, source
end
Ensure that your object source files begin with
a semicolon. Calling the help method should
dump the source header (minus the leading semicolon)
to your screen.
It will serve my purposes for now although I can
immediately think of some issues/improvements:
- all objects should be callable with only the
object name. With req'd parameters, you need
to know the usage before you can access the help
method - catch22.
- "help" should likely be its own object, taking
a MYOBJ__DEFINE string as a keyword parameter.
Comments?
Darran.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
|
|
|
|