source: trunk/addcmds.tcl @ 152

Last change on this file since 152 was 132, checked in by toby, 16 years ago

# on 2000/05/17 16:14:23, toby did:
cleanup adding histograms to be prettier and to avoid paths for files
in the same directory as the .EXP (better portability)

  • Property rcs:author set to toby
  • Property rcs:date set to 2000/05/17 16:14:23
  • Property rcs:lines set to +20 -11
  • Property rcs:rev set to 1.4
  • Property rcs:state set to Exp
  • Property svn:keywords set to Author Date Revision Id
File size: 20.1 KB
Line 
1# $Id: addcmds.tcl 132 2009-12-04 23:00:56Z toby $
2
3proc MakeAddPhaseBox {} {
4    global expmap
5
6    set nextphase ""
7    foreach p {1 2 3 4 5 6 7 8 9} {
8        if {[lsearch $expmap(phaselist) $p] == -1} {
9            set nextphase $p
10            break
11        }
12    }
13
14    # no more room
15    if {$nextphase == ""} {
16        tk_dialog .phaseerr "Add Phase Error" \
17                "There are already 9 phases. You cannot add more." \
18                error 0 "OK" 
19        return
20    }
21
22    set np .newphase
23    catch {destroy $np}
24    toplevel $np
25
26    grid [label $np.l1 -text "Adding phase #$nextphase"] \
27            -column 0 -row 0 -sticky w
28    grid [label $np.l2 -text "Phase title:"] -column 0 -row 1 
29    grid [entry $np.t1 -width 68] -column 1 -row 1 -columnspan 8
30    grid [label $np.l3 -text "Space Group:"] -column 0 -row 2 
31    grid [entry $np.t2 -width 12] -column 1 -row 2 
32    grid [frame $np.f -bd 4 -relief groove] -column 3 -row 2 -columnspan 8
33    set col -1
34    foreach i {a b c} {
35        grid [label $np.f.l1$i -text $i] -column [incr col] -row 1
36        grid [entry $np.f.e1$i -width 12] -column [incr col]  -row 1
37    }
38    set col -1
39    foreach i {a b g} {
40        grid [label $np.f.l2$i -text $i -font symbol] -column [incr col] -row 2
41        grid [entry $np.f.e2$i -width 12] -column [incr col]  -row 2
42        $np.f.e2$i insert 0 90.
43    }   
44   
45    grid [button $np.b1 -text Add \
46            -command "addphase $np"] -column 2 -row 3
47    bind $np <Return> "addphase $np"
48    grid [button $np.b2 -text Cancel \
49            -command "destroy $np"] -column 3 -row 3
50   
51    wm title $np "add new phase"
52
53    # grab focus, etc.
54    putontop $np
55
56    tkwait window $np
57
58    # fix focus...
59    afterputontop
60}
61
62proc addphase {np} {
63    global expgui
64    # validate the input
65    set err {}
66    set title [$np.t1 get]
67    if {[string trim $title] == ""} {
68        append err "  Title cannot be blank\n"
69    }
70    set spg [$np.t2 get]
71    if {[string trim $spg] == ""} {
72        append err "  Space group cannot be blank\n"
73    }
74    foreach i {a b c} {
75        set cell($i) [$np.f.e1$i get]
76        if {[string trim $cell($i)] == ""} {
77            append err "  $i cannot be blank\n"
78        } elseif {[catch {expr $cell($i)}]} {
79            append err "  $i is not valid\n"
80        }
81    }
82
83    foreach i {a b g} lbl {alpha beta gamma} {
84        set cell($lbl) [$np.f.e2$i get]
85        if {[string trim $cell($lbl)] == ""} {
86            append err "  $lbl cannot be blank\n"
87        } elseif {[catch {expr $cell($lbl)}]} {
88            append err "  $lbl is not valid\n"
89        }
90    }
91
92    if {$err != ""} {
93        tk_dialog .phaseerr "Add Phase Error" \
94                "The following error(s) were found in your input:\n$err" \
95                error 0 "OK" 
96        return
97    }
98
99    # check the space group
100    set fp [open spg.in w]
101    puts $fp "N"
102    puts $fp "N"
103    puts $fp $spg
104    puts $fp "Q"
105    close $fp
106    global tcl_platform
107    catch {
108        if {$tcl_platform(platform) == "windows"} {
109            exec [file join $expgui(gsasexe) spcgroup.exe] < spg.in >& spg.out
110        } else {
111            exec [file join $expgui(gsasexe) spcgroup] < spg.in >& spg.out
112        }
113    }
114    set fp [open spg.out r]
115    set out [read $fp]
116    close $fp
117    # attempt to parse out the output (fix up if parse did not work)
118    if {[regexp "space group symbol.*>(.*)Enter a new space group symbol" \
119            $out a b ] != 1} {set b $out}
120    if {[string first Error $b] != -1} {
121        # got an error, show it
122        ShowBigMessage \
123                 $np.error \
124                 "Error processing space group\nReview error message below" \
125                 $b
126        return
127    } else {
128        # show the result and confirm
129        set opt [ShowBigMessage \
130                $np.check \
131                "Check the symmetry operators in the output below" \
132                $b \
133                {Continue Redo} ]
134        if {$opt > 1} return
135    }
136    file delete spg.in spg.out
137   
138    # ok do it!
139    set fp [open exptool.in w]
140    puts $fp "P"
141    puts $fp $title
142    puts $fp $spg
143    puts $fp "$cell(a) $cell(b) $cell(c) $cell(alpha) $cell(beta) $cell(gamma)"
144    puts $fp "/"
145    close $fp
146    global tcl_platform
147    # Save the current exp file
148    savearchiveexp
149    # disable the file changed monitor
150    set expgui(expModifiedLast) 0
151    set expnam [file root [file tail $expgui(expfile)]]
152    catch {
153        if {$tcl_platform(platform) == "windows"} {
154            exec [file join $expgui(gsasexe) exptool.exe] $expnam \
155                    < exptool.in >& exptool.out
156        } else {
157            exec [file join $expgui(gsasexe) exptool] $expnam \
158                    < exptool.in >& exptool.out
159        }
160    } errmsg
161    # load the revised exp file
162    loadexp $expgui(expfile)
163    set fp [open exptool.out r]
164    set out [read $fp]
165    close $fp
166    destroy $np
167    if {$errmsg != ""} {
168        append errmsg "\n" $out
169    } else {
170        set errmsg $out
171    }
172    ShowBigMessage \
173                 $np \
174                 "Please review the result from adding the phase" \
175                 $errmsg
176    file delete exptool.in exptool.out
177}
178
179proc MakeAddHistBox {} {
180    global expmap newhist
181
182    # --> should check here if room for another histogram, but only texture
183    # folks will ever need that
184
185    set np .newhist
186    catch {destroy $np}
187    toplevel $np
188
189    grid [label $np.l0 -text "Adding new histogram"] \
190            -column 0 -row 0 -sticky ew -columnspan 7
191    grid [label $np.l1 -text "Data file:"] -column 0 -row 1 
192    grid [label $np.t1 -textvariable newhist(rawfile) -bd 2 -relief ridge] \
193            -column 1 -row 1 -columnspan 3 -sticky ew
194    grid [button $np.b1 -text "Select File" \
195            -command "getrawfile $np" \
196            ] -column 4 -row 1
197
198    grid [label $np.lbank -text "Select bank" -anchor w] -column 1 -row 2 -sticky w
199    grid [frame $np.bank]  -column 2 -row 2 -columnspan 7 -sticky ew
200
201    grid [label $np.l2 -text "Instrument\nParameter file:"] -column 0 -row 3
202    grid [label $np.t2 -textvariable newhist(instfile) -bd 2 -relief ridge] \
203            -column 1 -row 3 -columnspan 3 -sticky ew
204    grid [button $np.b2 -text "Select File" \
205            -command "getinstfile $np" \
206            ] -column 4 -row 3
207
208    grid [label $np.lset -text "Select set" -anchor w] -column 1 -row 4 -sticky w
209    grid [frame $np.set]  -column 2 -row 4 -columnspan 7 -sticky ew
210
211    grid [label $np.l3 -text "Usable data limit:"] -column 0 -row 5 -rowspan 2 
212    grid [entry $np.e3 -width 12 -textvariable newhist(2tLimit) \
213            ] -column 1 -row 5 -rowspan 2 
214    grid [radiobutton $np.cb3 -text "D-min" -variable newhist(LimitMode) \
215            -value 0] -column 2 -row 5 -sticky w
216    grid [radiobutton $np.cb4 -text "2-Theta Max" -variable newhist(LimitMode)\
217            -value 1] -column 2 -row 6 -sticky w
218   
219    grid [frame $np.f6] -column 1 -row 7 -columnspan 3
220    grid [button $np.f6.b6a -text Add \
221            -command "addhist $np"] -column 0 -row 0
222    bind $np <Return> "addhist $np"
223    grid [button $np.f6.b6b -text Cancel \
224            -command "destroy $np"] -column 1 -row 0
225   
226    grid columnconfigure $np 3 -weight 1
227
228    wm title $np "add new histogram"
229
230    if {[string trim $newhist(rawfile)] != {}} {
231        validaterawfile $np $newhist(rawfile)
232    }
233    if {[string trim $newhist(instfile)] != {}} {
234        validateinstfile $np $newhist(instfile)
235    }
236    set newhist(banknum) {}
237    set newhist(setnum) {}
238    #    for {set i 0} {$i<100} {incr i} {set newhist(bank$i) 0}
239    #    for {set i 0} {$i<100} {incr i} {set newhist(set$i) 0}
240
241    # grab focus, etc.
242    putontop $np
243
244    tkwait window $np
245
246    # fix focus...
247    afterputontop
248}
249
250# convert a file to Win-95 direct access
251proc WinCvt {file} {
252    global expgui
253    if ![file exists $file] {
254        tk_dialog .warn "Convert Error" \
255                "File $file does not exist" question 0 "OK"
256        return
257    }
258
259    set tmpname "[file join [file dirname $file] tempfile.xxx]"
260    set oldname "[file rootname $file].org"
261    if [file exists $oldname] {
262        set ans [tk_dialog .warn "OK to overwrite?" \
263                "File [file tail $oldname] exists in [file dirname $oldname]. OK to overwrite?" question 0 \
264                "Yes" "No"]
265        if $ans return
266        catch {file delete $oldname}
267    }
268
269    if [catch {
270        set in [open $file r]
271        # needed to test under UNIX
272        set out [open $tmpname w]
273        fconfigure $out -translation crlf
274        set len [gets $in line]
275        if {$len > 160} {
276            # this is a UNIX file. Hope there are no control characters
277            set i 0
278            set j 79
279            while {$j < $len} {
280                puts $out [string range $line $i $j]
281                incr i 80
282                incr j 80
283            }
284        } else {
285            while {$len >= 0} {
286                append line "                                        "
287                append line "                                        "
288                set line [string range $line 0 79]
289                puts $out $line
290                set len [gets $in line]
291            }
292        }
293        close $in
294        close $out
295        file rename $file $oldname
296        file rename $tmpname $file
297    } errmsg] {
298        tk_dialog .warn Notify "Error in conversion:\n$errmsg" warning 0 OK
299    }
300    return $file
301}
302
303proc getrawfile {np} {
304    global newhist tcl_platform
305    if {$tcl_platform(platform) == "windows"} {
306        set inp [
307        tk_getOpenFile -parent $np -initialfile $newhist(rawfile) -filetypes {
308            {"Data files" .GSAS} {"Data files" .GSA} 
309            {"Data files" .RAW}  {"All files" *}
310        }
311        ]
312    } else {
313        set inp [
314        tk_getOpenFile -parent $np -initialfile $newhist(rawfile) -filetypes {
315            {"Data files" .GSA*} {"Data files" .RAW} 
316            {"Data files" .gsa*} {"Data files" .raw} 
317            {"All files" *}
318        } 
319        ]
320    }
321    validaterawfile $np $inp
322}
323
324proc validaterawfile {np inp} {
325    global tcl_platform expgui newhist
326    if {$inp == ""} return
327    if [catch {set in [open $inp r]}] {
328        tk_dialog .err "Open error" "Unable to open file $inp" \
329                error 0 OK
330        return 
331    }
332    set newhist(banklist) {}
333    foreach child [pack slaves $np.bank] {destroy $child}
334    # is this a properly formatted file?
335    if {$tcl_platform(platform) == "windows"} {
336        # are lines the correct length?
337
338        #--> can we check that lines are terminated CR-LF?
339
340        set i 0
341        while {[set len [gets $in line]] > 0} {
342            incr i
343            if {$len != 80} {
344                set ans [tk_dialog .err "Read error" \
345                        "File $inp is not direct access. OK to convert?" \
346                        error 0 OK QUIT]
347                if {$ans == 0} {
348                    close $in
349                    WinCvt $inp
350                    set i 0
351                    set in [open $inp r]
352                    set line {}
353                } else {
354                    return
355                }
356            }
357            # scan for BANK lines
358            if {[string first BANK $line] == 0} {
359                scan $line "BANK%d" num
360                lappend newhist(banklist) $num
361            }
362            # check for "Instrument parameter file" line
363            if {$i == 2 && [string first "Instrument parameter" $line] == 0} {
364                validateinstfile $np \
365                        [file join [file dirname $inp] \
366                        [string trim [string range $line 26 end]]]
367            }
368        }
369    } else {
370        # is the file one big record?
371        set len [gets $in line]
372        # a instrument parameter file should be more than 4 lines
373        if {$len <= 4*80} {
374            set ans [tk_dialog .err "Read error" \
375                    "File $inp is not direct access. OK to convert?" \
376                    error 0 OK QUIT]
377            if {$ans == 0} {
378                close $in
379                set oldname ${inp}.original
380                file rename $inp $oldname
381                if [catch {
382                    exec [file join $expgui(gsasexe) convstod] < \
383                            $oldname > $inp
384                } errmsg] {
385                    tk_dialog .warn Notify \
386                            "Error in conversion:\n$errmsg" warning 0 OK
387                }
388                set in [open $inp r]
389                set line {}
390            } else {
391                return
392            }
393        }
394        seek $in 0
395        set i 0
396        while {[string length [set line [read $in 80]]] == 80} {
397            incr i
398            # scan for BANK lines
399            if {[string first BANK $line] == 0} {
400                scan $line "BANK%d" num
401                lappend newhist(banklist) $num
402            }
403            # check for "Instrument parameter file" line
404            if {$i == 2 && [string first "Instrument parameter" $line] == 0} {
405                validateinstfile $np \
406                        [file join [file dirname $inp] \
407                        [string trim [string range $line 26 end]]]
408            }
409        }
410    }
411    # were banks found?
412    if {$newhist(banklist) == ""} {
413        tk_dialog .err "Read error" \
414                "File $inp has no BANK lines. This is not a valid GSAS data file." \
415                error 0 OK
416        return
417    }
418    # don't use a full path unless needed
419    if {[pwd] == [file dirname $inp]} {
420        set newhist(rawfile) [file tail $inp]
421    } else {
422        set newhist(rawfile) $inp
423    }
424    foreach i $newhist(banklist) {
425        pack [radiobutton $np.bank.$i -text $i \
426                -variable newhist(banknum) -value $i] -side left
427        # only 1 choice, so set it
428        if {[llength $newhist(banklist)] == 1} {set newhist(banknum) $i}
429    }
430}
431
432proc getinstfile {np} {
433    global newhist tcl_platform
434    if {$tcl_platform(platform) == "windows"} {
435        set inp [
436        tk_getOpenFile -parent $np -initialfile $newhist(instfile) -filetypes {
437            {"Inst files" .INST} {"Inst files" .INS} 
438            {"Inst files" .PRM} {"All files" *}
439        }
440        ]
441    } else {
442        set inp [
443        tk_getOpenFile -parent $np -initialfile $newhist(instfile) -filetypes {
444            {"Inst files" .INS*} {"Inst files" .ins*} 
445            {"Inst files" .PRM}  {"Inst files" .prm} 
446            {"All files" *}
447        }
448        ]
449    }
450    validateinstfile $np $inp
451}
452
453proc validateinstfile {np inp} {
454    global tcl_platform expgui newhist
455    if {$inp == ""} return
456    if [catch {set in [open $inp r]}] {
457        tk_dialog .err "Open error" "Unable to open file $inp" \
458                error 0 OK
459        return 
460    }
461    set newhist(instbanks) {}
462    foreach child [pack slaves $np.set] {destroy $child}
463    # is this a properly formatted file?
464    if {$tcl_platform(platform) == "windows"} {
465        # are lines the correct length?
466
467        #--> can we check that lines are terminated CR-LF?
468
469        while {[set len [gets $in line]] > 0} {
470            if {$len != 80} {
471                set ans [tk_dialog .err "Read error" \
472                        "File $inp is not direct access. OK to convert?" \
473                        error 0 OK QUIT]
474                if {$ans == 0} {
475                    close $in
476                    WinCvt $inp
477                    set in [open $inp r]
478                    set line {}
479                } else {
480                    return
481                }
482            }
483            # scan for the INS   BANK line
484            if {[string first "INS   BANK" $line] == 0} {
485                set newhist(instbanks) \
486                        [string trim [string range $line 12 end]]
487            }
488        }
489    } else {
490        # is the file one big record?
491        set len [gets $in line]
492        if {$len <= 80} {
493            set ans [tk_dialog .err "Read error" \
494                    "File $inp is not direct access. OK to convert?" \
495                    error 0 OK QUIT]
496            if {$ans == 0} {
497                close $in
498                set oldname ${inp}.original
499                file rename $inp $oldname
500                if [catch {
501                    exec [file join $expgui(gsasexe) convstod] < \
502                            $oldname > $inp
503                } errmsg] {
504                    tk_dialog .warn Notify \
505                            "Error in conversion:\n$errmsg" warning 0 OK
506                }
507                set in [open $inp r]
508                set line {}
509            } else {
510                return
511            }
512        }
513        seek $in 0
514        while {[string length [set line [read $in 80]]] == 80} {
515            # scan for the INS   BANK line
516            if {[string first "INS   BANK" $line] == 0} {
517                set newhist(instbanks) \
518                        [string trim [string range $line 12 end]]
519            }
520        }
521    }
522    # were banks found?
523    if {$newhist(instbanks) == ""} {
524        tk_dialog .err "Read error" \
525                "File $inp has no INS   BANK line. This is not a valid GSAS Instrument Parameter file." \
526                error 0 OK
527        return
528    }
529    # don't use a full path unless needed
530    if {[pwd] == [file dirname $inp]} {
531        set newhist(instfile) [file tail $inp]
532    } else {
533        set newhist(instfile) $inp
534    }
535    for {set i 1} {$i <= $newhist(instbanks)} {incr i} {
536        pack [radiobutton $np.set.$i -text $i \
537                -variable newhist(setnum) -value $i] -side left
538        if {$newhist(instbanks) == 1} {set newhist(setnum) $i}
539    }
540}
541
542proc addhist {np} {
543    global expgui newhist
544    # validate the input
545    set err {}
546    if {[string trim $newhist(rawfile)] == ""} {
547        append err "  No data file specified\n"
548    }
549    if {[string trim $newhist(instfile)] == ""} {
550        append err "  No instrument parameter file specified\n"
551    }
552    if {[string trim $newhist(banknum)] == ""} {
553            append err "  Bank number must be specified\n"
554    } elseif {[catch {expr $newhist(banknum)}]} {
555            append err "  Bank number is not valid\n"
556    }
557    if {[string trim $newhist(setnum)] == ""} {
558        append err "  Parameter set number must be specified\n"
559    } elseif {[catch {expr $newhist(setnum)}]} {
560        append err "  Parameter set number is not valid\n"
561    }
562    if {[string trim $newhist(2tLimit)] == ""} {
563        append err "  2Theta/d-space limit must be specified\n"
564    } elseif {[catch {expr $newhist(2tLimit)}]} {
565        append err "  The 2Theta/d-space limit is not valid\n"
566    }
567    if {[string trim $newhist(LimitMode)] == ""} {
568        append err "  Please choose between either a 2Theta or d-space limit\n"
569    }
570
571    if {$err != ""} {
572        tk_dialog .phaseerr "Add Histogram Error" \
573                "The following error(s) were found in your input:\n$err" \
574                error 0 "OK" 
575        return
576    }
577
578    # ok do it!
579    set fp [open exptool.in w]
580    puts $fp "H"
581    puts $fp $newhist(rawfile)
582    puts $fp $newhist(instfile)
583    puts $fp $newhist(banknum)
584    puts $fp $newhist(setnum)
585    if {$newhist(LimitMode)} {
586        puts $fp "T"
587    } else {
588        puts $fp "D"
589    }
590    puts $fp "$newhist(2tLimit)"
591    puts $fp "/"
592    puts $fp "X"
593    puts $fp "X"
594    close $fp
595    global tcl_platform
596    # Save the current exp file
597    savearchiveexp
598    # disable the file changed monitor
599    set expgui(expModifiedLast) 0
600    set expnam [file root [file tail $expgui(expfile)]]
601    catch {
602        if {$tcl_platform(platform) == "windows"} {
603            exec [file join $expgui(gsasexe) exptool.exe] $expnam \
604                    < exptool.in >& exptool.out
605        } else {
606            exec [file join $expgui(gsasexe) exptool] $expnam \
607                    < exptool.in >& exptool.out
608        }
609    } errmsg
610    # load the revised exp file
611    loadexp $expgui(expfile)
612    set fp [open exptool.out r]
613    set out [read $fp]
614    close $fp
615    destroy $np
616    if {$errmsg != ""} {
617        append errmsg "\n" $out
618    } else {
619        set errmsg $out
620    }
621    ShowBigMessage \
622                 $np \
623                 "Please review the result from adding the phase" \
624                 $errmsg
625    file delete exptool.in exptool.out
626}
627
628proc MakeAddAtomsBox {phase} {
629    global expmap
630
631    # is there room for more atoms? Well, we will check this later
632    if {$phase == ""} return
633    if {[llength $phase] != 1} return
634
635    set np .newatoms
636    catch {destroy $np}
637    toplevel $np
638
639    grid [label $np.l1 -text "Adding atoms to phase #$phase"] \
640            -column 0 -row 0 -sticky w -columnspan 10
641#    grid [label $np.l2 -text "Phase title:"] -column 0 -row 1
642    set row 1
643    set col -1
644    foreach i {Atom\ntype Name x y z Occ Uiso} {
645        grid [label $np.l_${row}$i -text $i] -column [incr col] -row $row
646    }
647
648    set row 2
649    set col -1
650    grid [entry $np.e${row}t -width 5] -column [incr col]  -row $row
651    grid [entry $np.e${row}n -width 8] -column [incr col]  -row $row
652    foreach i {x y z o u} {
653        grid [entry $np.e${row}$i -width 12] -column [incr col] -row $row
654    }
655    # default occupancy
656    $np.e${row}o delete 0 end
657    $np.e${row}o insert end 1.0
658    # default Uiso
659    $np.e${row}u delete 0 end
660    $np.e${row}u insert end 0.025
661    # default occupancy
662    $np.e${row}n delete 0 end
663    $np.e${row}n insert end (default)
664
665    grid [button $np.b1 -text Add \
666            -command "addatom $phase $np"] -column 2 -row 3
667    bind $np <Return> "addatom $phase $np"
668    grid [button $np.b2 -text Cancel \
669            -command "destroy $np"] -column 3 -row 3
670   
671    wm title $np "add new atom"
672
673    # grab focus, etc.
674    putontop $np
675
676    tkwait window $np
677
678    # fix focus...
679    afterputontop
680}
681
682proc addatom {phase np} {
683    global expgui env
684    # validate the input
685    set err {}
686    set row 2
687    if {[set type [string trim [$np.e${row}t get]]] == ""} {
688        append err "  No atom type specified\n"
689    }
690
691    set name [string trim [$np.e${row}n get]]
692    if {$name == "(default)"} {set name "/"}
693    if {$name == ""} {set name "/"}
694
695    foreach i {x y z o u} n {x y z Occ Uiso} {
696        if {[set $i [string trim [$np.e${row}$i get]]] == ""} {
697            append err "  No value specified for $n\n"
698        } elseif {[catch {expr [set $i]}]} {
699            append err "  The value for $n is invalid\n"
700        }
701    }
702
703    if {$err != ""} {
704        tk_dialog .phaseerr "Add Atom Error" \
705                "The following error(s) were found in your input:\n$err" \
706                error 0 "OK" 
707        return
708    }
709
710    # ok do it!
711    set fp [open exptool.in w]
712    puts $fp "A"
713    puts $fp $phase
714    # for now, only one atom at a time
715    puts $fp 1
716    puts $fp "$type $x $y $z $o $name I $u"
717    close $fp
718    # needed in UNIX
719    set env(ATOMDATA) [file join $expgui(gsasdir) data atmdata.dat]
720    # needed in Windows
721    set env(GSAS) [file nativename $expgui(gsasdir)]
722    global tcl_platform
723    # Save the current exp file
724    savearchiveexp
725    # disable the file changed monitor
726    set expgui(expModifiedLast) 0
727    set expnam [file root [file tail $expgui(expfile)]]
728    catch {
729        if {$tcl_platform(platform) == "windows"} {
730            exec [file join $expgui(gsasexe) exptool.exe] $expnam \
731                    < exptool.in >& exptool.out
732        } else {
733            exec [file join $expgui(gsasexe) exptool] $expnam \
734                    < exptool.in >& exptool.out
735        }
736    } errmsg
737    # load the revised exp file
738    loadexp $expgui(expfile)
739    set fp [open exptool.out r]
740    set out [read $fp]
741    close $fp
742    destroy $np
743    if {$errmsg != ""} {
744        append errmsg "\n" $out
745    } else {
746        set errmsg $out
747    }
748    ShowBigMessage \
749                 $np \
750                 "Please review the result from adding the atom" \
751                 $errmsg
752    file delete exptool.in exptool.out
753}
Note: See TracBrowser for help on using the repository browser.