# File vpp, line 515
def ask_selection(com=nil)
  prompt='vpp command (? for help): '
  com ||= ask(prompt)
  output = nil
  com.chomp!
  return 'continue' if com == ''
  booklet,twosided,selection,lpropt = nil,nil,'-',''
  help = "Examples of print commands:\n5       to print page 5\n5-      to print pages 5 through the end\n5-7     to print pages 5, 6 and 7\n-7      to print the first 7 pages\n5-7,19- to print pages 5, 6, 7 and 19 through the end\na       to print the whole document\n-       to print the whole document\na x3    to print 3 copies of the document\nx3      the same\n5 x3    to print 3 copies of page 5\nt       print the whole document twosided\nt 2-    print twosided starting at page 2\nb       to print the whole document as an a5 size booklet\nb -12   to print the first 12 pages as an a5 size booklet\nOther commands:\ne       (if called by mk) edit the tex source and rerun mk\nc       (if called by mk) rerun mk\nv       (re)view the ps/pdf file\noxyz    send pdf output to file xyz.pdf instead of printer\nh       display this help\n?       display this help\nq       quit\n"
  com.split.each do |c|
    case c
    when 'q':                          # drop on q
      if ENV['VPPCHECKSAVED'] && ! @saved
        puts "You requested saving but did not use the o command"
        puts "Another q will destroy your copy"
        @saved = true
        return 'continue'
      end
      rm_rf(TMP)
      return 'quit'
    when 'e': quit(nil,EDITEXIT)       # edit request for caller
    when 'c': quit(nil,COMPILEEXIT)    # re-compile request for caller
    when 's':                          # make sure o command will be used; used in scripting
      @save = true
      return 'continue'
    when 'v':                          # (re)view the ps/pdf data
      view(@viewer,@filename);
      return 'continue'
    when /^x([0-9]+)$/:                # x3 -> -#3
      lpropt = "-#"+$1
    when /^o(.*)/:                     # output to file instead of printer
      output = $1.sub(/\~/,ENV['HOME'])
      if output == ''
        puts("filename must follow o without spacing")
        return 'continue'
      end
      if output =~ /\//
        puts("filename may not contain /'s")
        return 'continue'
      end
      @saved = true
    when 'b':    booklet  = true       # print a5 booklet
    when 't':    twosided  = true      # print twosided
    when 'a':    selection = '-'       # print all
    when '-':    selection = '-'       # print all
    when /^((\d+-?\d*|\d*-?\d+),?)+$/: # n-m or n- or -m
      selection = c.sub(/,$/,'')
    when /^(\?|h)$/:
      puts input_options
      return 'continue'
    else
      puts "Illegal specification(s)"
      puts input_options
      return 'continue'
    end
  end
  # pages in range?
  selection.sub!(/^-/,'1-')             # -m means 1-m
  selection.sub!(/-$/,"-#{@pagecount}") # n- means n-@pagecount
  selection.split(/\D+/).each do |n|
    unless n.to_i.between?(1,@pagecount)
      puts "Illegal page number #{n}; PDF has #{@pagecount} pages"
      return 'continue'
    end
  end
  return selection,booklet,twosided,lpropt,output
end