pro free_in, chan, optarr, nopt

nopt = 0                                             ; initialise return
b = ' '
c = ' '                                             ; temporary strings
let = ' '
print, 'Give options required: (just RETURN for all of them)'
read, b                                             ; get input as string
b = strupcase(strtrim(b,2))                         ; trim and uppercase
if b eq '00'XB then begin                           ; null response = ALL
  if chan eq 1 then begin
     nopt = fix(5)
     optarr = [1,2,3,4,5,0,0,0,0,0]
 endif
  if chan eq 2 then begin
     nopt = 9
     optarr = [1,2,3,4,5,6,7,8,9,0]
  endif
  if chan eq 3 then begin
     nopt = 3
     optarr = [1,2,3,0,0,0,0,0,0,0]
  endif
  if chan eq 4 then begin
     nopt = 7
     optarr = [1,2,3,4,5,6,7,0,0,0]
  endif
endif else begin
  for i=0,strlen(b) do begin
     let = strmid(b,i,1)   
     if (let ne ',') and (let ne ' ') then begin    ; eliminate commas & 
        c = c + let                                 ; spaces
     endif
  endfor
  c = strtrim(c,2)                                  ; safety trim
  nopt = strlen(c)                                   ; number of valid inputs
  for i=0,nopt-1  do begin
    optarr(i) = fix(strmid(c,i,1))                  ; convert for o/p array
  endfor
 endelse
return
end