1 | if {[llength $argv] != 1} { |
---|
2 | wm withdraw . |
---|
3 | tk_dialog .err {Wrong Args} \ |
---|
4 | "$argv0: argument should be a .EXP file name" \ |
---|
5 | error 0 Continue |
---|
6 | exit |
---|
7 | } |
---|
8 | |
---|
9 | package require Tk |
---|
10 | |
---|
11 | set filename [lindex $argv 0] |
---|
12 | |
---|
13 | set expgui(font) 14 |
---|
14 | set expgui(debug) 0 |
---|
15 | |
---|
16 | pack [label .l -text "Reading $filename\nPlease wait"] |
---|
17 | update |
---|
18 | wm protocol . WM_DELETE_WINDOW {puts ""; exit} |
---|
19 | #============================================================================= |
---|
20 | #---------------------------------------------------------------- |
---|
21 | # where are we? |
---|
22 | set expgui(script) [info script] |
---|
23 | # translate links -- go six levels deep |
---|
24 | foreach i {1 2 3 4 5 6} { |
---|
25 | if {[file type $expgui(script)] == "link"} { |
---|
26 | set link [file readlink $expgui(script)] |
---|
27 | if { [file pathtype $link] == "absolute" } { |
---|
28 | set expgui(script) $link |
---|
29 | } { |
---|
30 | set expgui(script) [file dirname $expgui(script)]/$link |
---|
31 | } |
---|
32 | } else { |
---|
33 | break |
---|
34 | } |
---|
35 | } |
---|
36 | # fixup relative paths |
---|
37 | if {[file pathtype $expgui(script)] == "relative"} { |
---|
38 | set expgui(script) [file join [pwd] $expgui(script)] |
---|
39 | } |
---|
40 | set expgui(scriptdir) [file dirname $expgui(script) ] |
---|
41 | #---------------------------------------------------------------- |
---|
42 | source [file join $expgui(scriptdir) opts.tcl] |
---|
43 | # fetch EXP file processing routines |
---|
44 | source [file join $expgui(scriptdir) readexp.tcl] |
---|
45 | # commands for running GSAS programs |
---|
46 | #source [file join $expgui(scriptdir) gsascmds.tcl] |
---|
47 | # override options with locally defined values |
---|
48 | set filelist [file join $expgui(scriptdir) localconfig] |
---|
49 | if {$tcl_platform(platform) == "windows"} { |
---|
50 | lappend filelist "c:/gsas.config" |
---|
51 | } else { |
---|
52 | lappend filelist [file join ~ .gsas_config] |
---|
53 | } |
---|
54 | catch { |
---|
55 | foreach file $filelist { |
---|
56 | if [file exists $file] {source $file} |
---|
57 | } |
---|
58 | } |
---|
59 | SetTkDefaultOptions $expgui(font) |
---|
60 | |
---|
61 | if {![file exists $filename]} { |
---|
62 | # read error |
---|
63 | wm withdraw . |
---|
64 | tk_dialog .err {Bad file} \ |
---|
65 | "$argv0: error\nfile $filename not found" \ |
---|
66 | error 0 Continue |
---|
67 | exit |
---|
68 | } |
---|
69 | set fmt [expload $filename] |
---|
70 | if {$fmt < 0} { |
---|
71 | # read error |
---|
72 | wm withdraw . |
---|
73 | tk_dialog .err {Bad file} \ |
---|
74 | "$argv0: error reading $filename\nThis is not a valid GSAS .EXP file" \ |
---|
75 | error 0 Continue |
---|
76 | exit |
---|
77 | } |
---|
78 | mapexp |
---|
79 | set list1 {} |
---|
80 | foreach hist $expmap(powderlist) { |
---|
81 | set list2 $hist |
---|
82 | set instcons {} |
---|
83 | foreach item {difc difa zero ipola pola} { |
---|
84 | lappend instcons [histinfo $hist $item] |
---|
85 | } |
---|
86 | lappend list2 "$expmap(htype_$hist) [list $instcons]" |
---|
87 | foreach i $expmap(phaselist_$hist) { |
---|
88 | set list $i |
---|
89 | lappend list [string trim [hapinfo $hist $i proftype]] |
---|
90 | lappend list [hapinfo $hist $i pcut] |
---|
91 | set nterms [hapinfo $hist $i profterms] |
---|
92 | for { set num 1 } { $num <= $nterms } { incr num } { |
---|
93 | lappend list [hapinfo $hist $i pterm$num] |
---|
94 | } |
---|
95 | lappend list2 $list |
---|
96 | } |
---|
97 | lappend list1 $list2 |
---|
98 | } |
---|
99 | puts $list1 |
---|
100 | exit |
---|