Changeset 113
- Timestamp:
- Dec 4, 2009 5:00:37 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/addcmds.tcl
- Property rcs:date changed from 1999/07/22 20:08:20 to 1999/10/11 19:49:28
- Property rcs:lines changed from +3 -1 to +24 -8
- Property rcs:rev changed from 1.2 to 1.3
r99 r113 158 158 < exptool.in >& exptool.out 159 159 } 160 } 160 } errmsg 161 161 # load the revised exp file 162 162 loadexp $expgui(expfile) … … 165 165 close $fp 166 166 destroy $np 167 if {$errmsg != ""} { 168 append errmsg "\n" $out 169 } else { 170 set errmsg $out 171 } 167 172 ShowBigMessage \ 168 173 $np \ 169 174 "Please review the result from adding the phase" \ 170 $ out175 $errmsg 171 176 file delete exptool.in exptool.out 172 177 } … … 360 365 [file join [file dirname $inp] \ 361 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 set newhist(rawfile) $inp 419 foreach i $newhist(banklist) { 420 # pack [checkbutton $np.bank.$i -text $i \ 421 # -variable newhist(bank$i)] -side left 422 pack [radiobutton $np.bank.$i -text $i \ 423 -variable newhist(banknum) -value $i] -side left 424 } 425 } 426 427 proc getinstfile {np} { 428 global newhist tcl_platform 429 if {$tcl_platform(platform) == "windows"} { 430 set inp [ 431 tk_getOpenFile -parent $np -initialfile $newhist(instfile) -filetypes { 432 {"Inst files" .INST} {"Inst files" .INS} 433 {"Inst files" .PRM} {"All files" *} 434 } 435 ] 436 } else { 437 set inp [ 438 tk_getOpenFile -parent $np -initialfile $newhist(instfile) -filetypes { 439 {"Inst files" .INS*} {"Inst files" .ins*} 440 {"Inst files" .PRM} {"Inst files" .prm} 441 {"All files" *} 442 } 443 ] 444 } 445 validateinstfile $np $inp 446 } 447 448 proc validateinstfile {np inp} { 449 global tcl_platform expgui newhist 450 if {$inp == ""} return 451 if [catch {set in [open $inp r]}] { 452 tk_dialog .err "Open error" "Unable to open file $inp" \ 453 error 0 OK 454 return 455 } 456 set newhist(instbanks) {} 457 foreach child [pack slaves $np.set] {destroy $child} 458 # is this a properly formatted file? 459 if {$tcl_platform(platform) == "windows"} { 460 # are lines the correct length? 461 462 #--> can we check that lines are terminated CR-LF? 463 464 while {[set len [gets $in line]] > 0} { 465 if {$len != 80} { 466 set ans [tk_dialog .err "Read error" \ 467 "File $inp is not direct access. OK to convert?" \ 468 error 0 OK QUIT] 469 if {$ans == 0} { 470 close $in 471 WinCvt $inp 472 set in [open $inp r] 473 set line {} 474 } else { 475 return 476 } 477 } 478 # scan for the INS BANK line 479 if {[string first "INS BANK" $line] == 0} { 480 set newhist(instbanks) \ 481 [string trim [string range $line 12 end]] 362 482 } 363 483 } … … 387 507 } 388 508 seek $in 0 389 set i 0390 while {[string length [set line [read $in 80]]] == 80} {391 incr i392 # scan for BANK lines393 if {[string first BANK $line] == 0} {394 scan $line "BANK%d" num395 lappend newhist(banklist) $num396 }397 # check for "Instrument parameter file" line398 if {$i == 2 && [string first "Instrument parameter" $line] == 0} {399 validateinstfile $np \400 [file join [file dirname $inp] \401 [string trim [string range $line 26 end]]]402 }403 }404 }405 # were banks found?406 if {$newhist(banklist) == ""} {407 tk_dialog .err "Read error" \408 "File $inp has no BANK lines. This is not a valid GSAS data file." \409 error 0 OK410 return411 }412 set newhist(rawfile) $inp413 foreach i $newhist(banklist) {414 # pack [checkbutton $np.bank.$i -text $i \415 # -variable newhist(bank$i)] -side left416 pack [radiobutton $np.bank.$i -text $i \417 -variable newhist(banknum) -value $i] -side left418 }419 }420 421 proc getinstfile {np} {422 global newhist tcl_platform423 if {$tcl_platform(platform) == "windows"} {424 set inp [425 tk_getOpenFile -parent $np -initialfile $newhist(instfile) -filetypes {426 {"Inst files" .INST} {"Inst files" .INS}427 {"Inst files" .PRM} {"All files" *}428 }429 ]430 } else {431 set inp [432 tk_getOpenFile -parent $np -initialfile $newhist(instfile) -filetypes {433 {"Inst files" .INS*} {"Inst files" .ins*}434 {"Inst files" .PRM} {"Inst files" .prm}435 {"All files" *}436 }437 ]438 }439 validateinstfile $np $inp440 }441 442 proc validateinstfile {np inp} {443 global tcl_platform expgui newhist444 if {$inp == ""} return445 if [catch {set in [open $inp r]}] {446 tk_dialog .err "Open error" "Unable to open file $inp" \447 error 0 OK448 return449 }450 set newhist(instbanks) {}451 foreach child [pack slaves $np.set] {destroy $child}452 # is this a properly formatted file?453 if {$tcl_platform(platform) == "windows"} {454 # are lines the correct length?455 456 #--> can we check that lines are terminated CR-LF?457 458 while {[set len [gets $in line]] > 0} {459 if {$len != 80} {460 set ans [tk_dialog .err "Read error" \461 "File $inp is not direct access. OK to convert?" \462 error 0 OK QUIT]463 if {$ans == 0} {464 close $in465 WinCvt $inp466 set in [open $inp r]467 set line {}468 } else {469 return470 }471 }472 # scan for the INS BANK line473 if {[string first "INS BANK" $line] == 0} {474 set newhist(instbanks) \475 [string trim [string range $line 12 end]]476 }477 }478 } else {479 # is the file one big record?480 set len [gets $in line]481 if {$len <= 80} {482 set ans [tk_dialog .err "Read error" \483 "File $inp is not direct access. OK to convert?" \484 error 0 OK QUIT]485 if {$ans == 0} {486 close $in487 set oldname ${inp}.original488 file rename $inp $oldname489 if [catch {490 exec [file join $expgui(gsasexe) convstod] < \491 $oldname > $inp492 } errmsg] {493 tk_dialog .warn Notify \494 "Error in conversion:\n$errmsg" warning 0 OK495 }496 set in [open $inp r]497 set line {}498 } else {499 return500 }501 }502 seek $in 0503 509 while {[string length [set line [read $in 80]]] == 80} { 504 510 # scan for the INS BANK line … … 592 598 < exptool.in >& exptool.out 593 599 } 594 } 600 } errmsg 595 601 # load the revised exp file 596 602 loadexp $expgui(expfile) … … 599 605 close $fp 600 606 destroy $np 607 if {$errmsg != ""} { 608 append errmsg "\n" $out 609 } else { 610 set errmsg $out 611 } 601 612 ShowBigMessage \ 602 613 $np \ 603 614 "Please review the result from adding the phase" \ 604 $ out615 $errmsg 605 616 file delete exptool.in exptool.out 606 617 } … … 714 725 < exptool.in >& exptool.out 715 726 } 716 } 727 } errmsg 717 728 # load the revised exp file 718 729 loadexp $expgui(expfile) … … 721 732 close $fp 722 733 destroy $np 734 if {$errmsg != ""} { 735 append errmsg "\n" $out 736 } else { 737 set errmsg $out 738 } 723 739 ShowBigMessage \ 724 740 $np \ 725 741 "Please review the result from adding the atom" \ 726 $ out742 $errmsg 727 743 file delete exptool.in exptool.out 728 744 }
Note: See TracChangeset
for help on using the changeset viewer.