~diesch/ubuntu/trusty/scid/fix-for-1277520

« back to all changes in this revision

Viewing changes to scripts/sc_tree.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Peter van Rossum
  • Date: 2002-04-06 14:49:15 UTC
  • Revision ID: james.westby@ubuntu.com-20020406144915-63pe79by11n28esy
Tags: upstream-3.2
ImportĀ upstreamĀ versionĀ 3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# \
 
3
exec tcscid "$0" "$@"
 
4
 
 
5
proc usage {} {
 
6
  puts stderr {Usage: sc_tree [-eco <eco-file>] [-pgn <output-file>] <database> [moves...]}
 
7
  puts stderr {Example: sc_tree -pgn out.pgn mygames 1.e4 e6}
 
8
  exit 1
 
9
}
 
10
 
 
11
set ecoFile ""
 
12
set pgnFile ""
 
13
 
 
14
if {[llength $argv] == 0} { usage }
 
15
while {[lindex $argv 0] == "-eco"  ||  [lindex $argv 0] == "-pgn"} {
 
16
  if {[llength $argv] < 3} { usage }
 
17
  if {[lindex $argv 0] == "-eco"} {
 
18
    set ecoFile [lindex $argv 1]
 
19
  } else {
 
20
    set pgnFile [lindex $argv 1]
 
21
  }
 
22
  set argv [lrange $argv 2 end]
 
23
}
 
24
 
 
25
set base [lindex $argv 0]
 
26
set argv [lrange $argv 1 end]
 
27
if {[llength $argv] > 0  && [catch {eval sc_move addSan $argv} err]} {
 
28
  puts stderr "Error in move list: $err"
 
29
  exit 1
 
30
}
 
31
 
 
32
if {$ecoFile != ""} {
 
33
  if {[catch {sc_eco read $ecoFile} err]} {
 
34
    puts stderr "Unable to read ECO file: $ecoFile"
 
35
    exit 1
 
36
  }
 
37
}
 
38
 
 
39
if {[catch {sc_base open -fast -readonly $base} err]} {
 
40
  puts stderr "Error opening database \"$base\": $err"
 
41
  exit 1
 
42
}
 
43
 
 
44
puts [sc_tree search]
 
45
 
 
46
if {$pgnFile != ""} {
 
47
  puts ""
 
48
  if {[file exists $pgnFile]} {
 
49
    puts "Output file \"[file tail $pgnFile]\" already exists! It was not altered."
 
50
  } else {
 
51
    sc_base export filter PGN $pgnFile -comments 1 -variations 1
 
52
    puts "Wrote [sc_filter count] games to $pgnFile"
 
53
  }
 
54
}
 
55
 
 
56
sc_base close