function clabel(csiz,cformat,clist)

*-----------------------------------------------------------------------
*  Prompts user to plot contour labels using numbers in input variable
*  "clist"
*  "cformat" is the format of contour label number
*  "csiz" is the size of a single contour character in inches
*-----------------------------------------------------------------------

n=1
cl = subwrd(clist,n)
if( cl = '' )
  say
  say 'No elements in input "clist"...'
  say 'Exiting script'
  say
  exit
else
  while ( cl != '' )
    say
    say 'Contour label: 'cl
    clf = math_format(cformat,cl)
    say 'Formatted contour label: 'clf
    nclf = strlen(clf)
*    say 'Number of characters in 'clf' is 'nclf
    clsiz = nclf*csiz
*    say 'Contour label size for 'clf' is 'clsiz
    plot = 'y'
    while ( plot='y' | plot='yes' | plot='Y' | plot='Yes' )
      say 'Click where you want the center of the label'
      'query bpos'
      xbpos = subwrd(result,3)
      ybpos = subwrd(result,4)
      'query pp2xy 'xbpos' 'ybpos
      xc = subwrd(result,3)
      yc = subwrd(result,6)
      say 'Draw color filled rectangle centered at X Y: 'xc' 'yc
      recfw = clsiz+0.1*csiz ; recfw2 = recfw/2
*      say '... recfw recfw2: 'recfw' 'recfw2
      recfh = 1.4*csiz  ; recfh2 = recfh/2
*      say '... recfh recfh2: 'recfh' 'recfh2
      xlo = xc-recfw2 ; xhi = xc+recfw2
      ylo = yc-recfh2 ; yhi = yc+recfh2
*      say '... xlo ylo xhi yhi: 'xlo' 'ylo' 'xhi' 'yhi
      'set line 0'
      'draw recf 'xlo' 'ylo' 'xhi' 'yhi
      say 'Plot label centered at X Y: 'xc' 'yc
      'set string 1 c 4'
      'set strsiz 'csiz
      'draw string 'xc' 'yc' 'clf
      say
      say 'Do you want to plot this label again?'
      say 'Type y(es) or Y(es), or press "ENTER" to continue...'
      pull plot
    endwhile
    n=n+1
    cl = subwrd(clist,n)
  endwhile
  say
endif

return
