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

Home » Public Forums » archive » gurus: example code as main level code ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
gurus: example code as main level code ? [message #32766] Fri, 01 November 2002 09:04
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
Greetings all,

I am going through my monster IDL library, and was wondering what
people think of the practice of including a main level "example" or
"Test" code at the end of each function and procedure?

Are there any reasons not to do this?
I don't see any, but I am probably missing something, i usually am :).

I do this almost always (and in fact, I am planning to make this a rule,
so that all my functions will have an example if anyone runs the function.


Cheers,
bob stockwell


As an example of what I mean, here is a tiny (but useful) function:
You call it as result = range(array), but if you want to see an
example of the function, just do
IDL>.run range


function range, ts,_extra=_extra

if n_elements(ts) lt 1 then return,-1
return, [min(ts,_extra=_extra),max(ts,_extra=_extra)]
end


a = findgen(10)+44

print,range(a)

end
[Message index]
 
Read Message
Previous Topic: Call_external Problem - File size limit exceed (core dump)
Next Topic: common variables between widgets

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

Current Time: Fri Oct 10 07:09:47 PDT 2025

Total time taken to generate the page: 0.23884 seconds