Opened 16 years ago

#73 new enhancement

more helpfull make_selection output

Reported by: pinsard Owned by: somebody
Priority: major Milestone:
Component: component1 Version:
Keywords: Cc:

Description

To make correction easier for end user of make_seection I suggest to
show all the "not found" items.

Here is an example from source :

IDL> vals = indgen(20)
IDL> index = MAKE_SELECTION(vals,[-1,-5,8,7,7,8,9],/REQUIRED)
% MAKE_SELECTION: Selected name not found in names array (-1)!

Only "-1" is point out, -5 should also be seen.

And with an additional keyword CHOICES for examples, it will be great to see quickly all the possibilities like

IDL> vals = indgen(5)
IDL> index = MAKE_SELECTION(vals,[-1,-5,8,7,7,8,9],/REQUIRED,/CHOICES)
% MAKE_SELECTION: Selected name not found in names array (-1)!
% MAKE_SELECTION: Selected name not found in names array (-5)!
% MAKE_SELECTION: 0, 1, 2, 3 or 4

here is a IDL source I wrote to do this :

 line=""
 last=n_elements(names)-1
 IF (n_elements(names) EQ 1) THEN BEGIN
    line = strtrim(names[0],2)
 ENDIF ELSE BEGIN
    FOR i=0,n_elements(names)-1 DO BEGIN
      IF ((i EQ 0) AND (i NE last)) THEN BEGIN
       line=strtrim(names[i],2)
      ENDIF
      IF ((i GE 1) AND (i NE last)) THEN BEGIN
       line=line + ', ' + strtrim(names[i],2)
      ENDIF
      IF (i EQ last) THEN BEGIN
       line=line + ' or ' + strtrim(names[i],2)
      ENDIF
    ENDFOR
  ENDELSE
   message,line,/CONT,NOPRINT=quiet

Of course line may be long ... very long so this is not the best way ... just an idea
.

Change History (0)

Note: See TracTickets for help on using tickets.