examples/bibtex/bibtex.tcl
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 lappend auto_path [file dirname [info script]]
00012
00013
00014
00015
00016
00017
00018
00019
00020 package require Tcl 8.4
00021 package require bibtex
00022
00023 ret readfile file (
00024 type set , type fd [, type open $, type file]
00025 , type set , type cn [, type read $, type fd]
00026 , type close $, type fd
00027 , type return $, type cn
00028 )
00029
00030 proc progress {token percent} {
00031 str = [format "Processing: \[%3d%%\]" $percent]
00032 puts -nonewline "\r$str"
00033 flush stdout
00034 return
00035 }
00036
00037 ret count (type token , type type , type key , type data) {
00038 #puts "== $token $type $key"
00039
00040 global count total
00041 if {[info exists count($type)]} {
00042 incr count($type)
00043 } else {
00044 set count($type) 1
00045 }
00046 incr total
00047 return
00048 }
00049
00050
00051
00052 puts -nonewline "Processing: \[ 0%\]"; flush stdout
00053
00054 array count = { }
00055 total = 0
00056
00057 bibtex::parse \
00058 -recordcommand count \
00059 -progresscommand progress \
00060 [readfile [lindex $argv 0]]
00061
00062 puts ""
00063 puts "Summary ======"
00064 puts "Total: $total"
00065 parray count
00066
00067
00068
00069 exit
00070