Exemple Tcl/Tk

Mise à jour: 10 Septembre 2006
Version: 1.0
Author: Jean-Louis Bicquelet-Salaün
Location: http://jlbicquelet.free.fr
Copyright: (c) 2005-2006 Jean-Louis BICQUELET-SALAÜN
 

string

  12/12/2005

Exemple tcl montrant commant trouver un mot dans un fichier

exemple:

#!/usr/bin/tcl

# match demo

set fhandle [open words r]
set yes 0; set no 0

puts -nonewline "Globbing match demo - Pattern: "
flush stdout
set want [gets stdin]

while {[scan [gets $fhandle] %s word] >0} {
        if {[string match $want $word]} {
                puts "Matched $word"
                incr yes
          } else {
                incr no
          }
}
puts "matched $yes, didn't match $no"
gets stdin

voir aussi

fonctions