[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Named Indices
David Fanning wrote:
> J.D. Smith (firstname.lastname@example.org) writes:
> > A slightly more portable solution, in the sense that it requires no modification
> > of startup code but simply inclusion of a program somewhere on the path
> > (presumably in the same directory tree as the program which would use it), is a
> > special purpose function. E.g.
> > plot, findgen(11), LINESTYLE=linestyle(/DASH)
> > You could even make an uber-function that encapsulates all such "named
> > entity"<->"integer value" constant mappings:
> > const(/LINESTYLE,/DASH) ; produces 2
> > const(/AXIS_STYLE,/FORCE,/SUPPRESS) ; produces 4 or 2 = 6
> > const(/SIZE,/INTEGER) ; produces 2
> > const(/WIDGET_DRAW_TYPE,/BUTTON_RELEASE) ; produces 1
> > const(/AXIS_NUMBER,/X) ; produces 0
> > const(/COLOR_TABLE,/PRISM) ; produces 6
> > etc.
> > The problem is you have to maintain it with new versions of IDL, and ensure
> > backwards compatibility too. Other issues crop up, such as private color table
> > lists, etc. It would definitely help readability though. Sounds like a great
> > beginner programming project that would readily educate one on the subtle
> > distinctions among keyword_set(), n_elements() ne 0, and arg_present().
> I thought about a function too, although not such
> a generic one. But I got this far:
> FUNCTION LS, Solid=Solid, Dot=Dot, Dash=Dash, DashDot=DashDot...
> When I realized I was in trouble with keyword names.
> In the end, I decided cryptic numbers were better
> than a long-winded explanation of how keyword names
> work. :-(
> But what I'm really surprised you didn't offer was
> a way to write a polymorphic object to do the job. :-)
I said it was a *beginner* function to code up, David. Intermediate users would
of course wrap it in a superclass so that new maps could be created at will by
self-aware plotting entities which lie hiding silently under your terminal and
creep out at night to plot things you'll never see. But then again, you'll need
to create that object sometime, perhaps in the startup file and then... o damn
we're back to where we started.
Ahh yes, the familiar "Ambiguous keyword abbreviation" a.k.a. a.k.a. The only
workaround being carnal manipulation of the _EXTRA structure. So that makes
this not so beginner a problem. You could always use strings instead, but
that's an extra character to type:
The solution is left as an exercise.
J.D. Smith /*\ WORK: (607) 255-6263
Cornell University Dept. of Astronomy \*/ (607) 255-5842
304 Space Sciences Bldg. /*\ FAX: (607) 255-5875
Ithaca, NY 14853 \*/