bind pub -|- !imdbq pub_imdb_quotes

proc save_imdb_quotes {} {
  global imdb_quotes
  set wfile [open scripts/imdb_quotes.dat w]
  foreach q $imdb_quotes(saved) {
    puts $wfile [html_replace $q]
  }
  close $wfile
}

proc load_imdb_quotes {} {
  global imdb_quotes
  if {![file exists scripts/imdb_quotes.dat]} {
    set wfile [open scripts/imdb_quotes.dat w]
    puts $wfile ""
    close $wfile
  }
  set rfile [open scripts/imdb_quotes.dat r]
  catch {unset imdb_quotes(saved)}
  while {![eof $rfile]} {
    set line [gets $rfile]
    if {$line==""} { continue }
    lappend imdb_quotes(saved) $line
  }
  close $rfile
  if {![info exists imdb_quotes(saved)]} { set imdb_quotes(saved) "" }
}

load_imdb_quotes
