Changeset 384 for trunk/gsascmds.tcl
- Timestamp:
- Dec 4, 2009 5:05:16 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsascmds.tcl
- Property rcs:date changed from 2001/04/16 21:27:22 to 2001/04/17 22:49:47
- Property rcs:lines changed from +3 -3 to +20 -223
- Property rcs:rev changed from 1.30 to 1.31
r380 r384 861 861 } 862 862 } else { 863 tk_dialog .warn"No Browser" \864 "Could not find a browser. Netscape is not in path. Define environment variable BROWSER to be full path name of browser." \865 warn 0 OK863 MyMessageBox -parent . -title "No Browser" \ 864 -message "Could not find a browser. Netscape is not in path. Define environment variable BROWSER to be full path name of browser." \ 865 -icon warn 866 866 } 867 867 } … … 1133 1133 } 1134 1134 if {$errmsg != ""} { 1135 tk_dialog .errorMsg "Export error" $errmsg warning 0 "OK" 1135 MyMessageBox -parent . -title "Export error" \ 1136 -message "Export error: $errmsg" -icon warning 1136 1137 return 1137 1138 } … … 1180 1181 } errmsg] { 1181 1182 catch {close $fp} 1182 tk_dialog .errorMsg "Export error" $errmsg warning 0 "OK" 1183 MyMessageBox -parent . -title "Export error" \ 1184 -message "Export error: $errmsg" -icon warning 1183 1185 } else { 1184 1186 catch {close $fp} … … 1387 1389 1388 1390 #------------------------------------------------------------------------------ 1389 # file conversion for UNIX1391 # file conversions 1390 1392 #------------------------------------------------------------------------------ 1391 # convert a file1392 1393 proc convfile {} { 1393 global tcl_platform1394 if {$tcl_platform(platform) == "windows"} {1395 convwin1396 } else {1397 convunix1398 }1399 }1400 1401 # file conversions for UNIX (convstod convdtos)1402 proc convunix {} {1403 global expgui infile outfile1404 set frm .file1405 catch {destroy $frm}1406 toplevel $frm1407 wm title $frm "Convert File"1408 bind $frm <Key-F1> "MakeWWWHelp expgui.html ConvertUnix"1409 1410 pack [frame [set frm0 $frm.0] -bd 2 -relief groove] \1411 -padx 3 -pady 3 -side top -fill x1412 pack [frame $frm.mid] -side top1413 pack [frame [set frmA $frm.mid.1] -bd 2 -relief groove] \1414 -padx 3 -pady 3 -side left1415 pack [label $frmA.0 -text "Select an input file"] -side top -anchor center1416 pack [frame [set frmB $frm.mid.2] -bd 2 -relief groove] \1417 -padx 3 -pady 3 -side left1418 pack [label $frmB.0 -text "Enter an output file"] -side top -anchor center1419 pack [frame [set frmC $frm.3] ] -padx 3 -pady 3 -side top -fill x -expand y1420 1421 pack [label $frm0.1 -text "Convert to:"] -side top -anchor center1422 pack [frame $frm0.2] -side top -anchor center1423 pack [radiobutton $frm0.2.d -text "direct access" -value convstod \1424 -command setoutfile \1425 -variable outfile(type)] -side left -anchor center1426 pack [radiobutton $frm0.2.s -text "sequential" -value convdtos \1427 -command setoutfile \1428 -variable outfile(type)] -side right -anchor center1429 set outfile(type) ""1430 1431 pack [button $frmC.b -text Convert -command "valid_conv_unix"] -side left1432 pack [button $frmC.q -text Quit -command "set infile(done) 1"] -side left1433 pack [button $frmC.help -text Help -bg yellow \1434 -command "MakeWWWHelp expgui.html ConvertUnix"] \1435 -side right1436 1437 unixcnvbox $frmA infile 11438 unixcnvbox $frmB outfile 01439 set infile(done) 01440 bind $frm <Return> "valid_conv_unix"1441 # force the window to stay on top1442 putontop $frm1443 focus $frmC.q1444 update1445 tkwait variable infile(done)1446 destroy $frm1447 afterputontop1448 }1449 1450 # validate the files and make the conversion -- unix1451 proc valid_conv_unix {} {1452 global infile outfile expgui1453 set error {}1454 if {$outfile(type) == "convstod" || $outfile(type) == "convdtos"} {1455 set convtype $outfile(type)1456 } else {1457 append error "You must specify a conversion method: to direct access or to sequential.\n"1458 }1459 if {$infile(name) == ""} {1460 append error "You must specify an input file to convert.\n"1461 }1462 if {$outfile(name) == ""} {1463 append error "You must specify an output file name for the converted file.\n"1464 }1465 if {$error != ""} {1466 tk_dialog .warn Notify $error warning 0 OK1467 return1468 }1469 1470 if {$infile(name) == $outfile(name)} {1471 MyMessageBox -parent . -title Notify \1472 -message "Sorry, filenames must differ" \1473 -icon warning -helplink "expguierr.html ConvSameName"1474 tk_dialog .warn Notify "Sorry, filenames must differ" warning 0 OK1475 return1476 }1477 if ![file exists [file join $infile(dir) $infile(name)]] {1478 MyMessageBox -parent . -title Notify \1479 -message "Sorry, file $infile(name) not found in $infile(dir)" \1480 -icon warning -helplink "expguierr.html ConvNotFound"1481 return1482 }1483 if [file exists [file join $outfile(dir) $outfile(name)]] {1484 set ans [MyMessageBox -parent . -title "Overwrite?" \1485 -message "Warning: file $outfile(name) exists in $outfile(dir). OK to overwrite?" \1486 -icon warning -type {Overwrite Cancel} -default Overwrite \1487 -helplink "expguierr.html OverwriteCnv"]1488 if {[string tolower $ans] == "cancel"} return1489 }1490 if [catch {1491 exec [file join $expgui(gsasexe) $convtype] < \1492 [file join $infile(dir) $infile(name)] > \1493 [file join $outfile(dir) $outfile(name)]1494 } errmsg] {1495 tk_dialog .warn Notify "Error in conversion:\n$errmsg" warning 0 OK1496 } else {1497 if [tk_dialog .converted Notify \1498 "File converted. Convert more files?" \1499 "" 0 Yes No] {set infile(done) 1}1500 }1501 }1502 1503 # create a file box for UNIX conversions1504 proc unixcnvbox {bx filvar diropt} {1505 global ${filvar} expgui1506 pack [frame $bx.top] -side top1507 pack [label $bx.top.a -text "Directory" ] -side left1508 set ${filvar}(FileDirButtonMenu) [tk_optionMenu $bx.top.d ${filvar}(dir) [pwd] ]1509 pack $bx.top.d -side left1510 set ${filvar}(dir) [pwd]1511 1512 # pack [label $bx.d -textvariable ${filvar}(dir) -bd 2 -relief raised ] -side top1513 # set ${filvar}(dir) [pwd]1514 1515 pack [frame $bx.a -width 200 -height 75] -side top -expand yes -fill both1516 listbox $bx.a.files -relief raised -bd 2 \1517 -yscrollcommand "$bx.a.scroll set" \1518 -height 15 -width 0 -exportselection 01519 scrollbar $bx.a.scroll -command "$bx.a.files yview"1520 unixFilChoose $bx $bx.a.files $filvar $diropt1521 if {$filvar == "infile"} {1522 bind $bx.a.files <ButtonRelease-1> \1523 "unixFilChoose $bx $bx.a.files $filvar $diropt; setoutfile"1524 } else {1525 bind $bx.a.files <ButtonRelease-1> \1526 "unixFilChoose $bx $bx.a.files $filvar $diropt"1527 }1528 pack $bx.a.scroll -side left -fill y1529 pack $bx.a.files -side left -fill both -expand yes1530 pack [entry $bx.c -textvariable ${filvar}(name)] -side top1531 }1532 1533 # select a file or directory, also called when box is created to fill it1534 proc unixFilChoose {frm box filvar {dironly 1}} {1535 global $filvar1536 set select [$box curselection]1537 if {$select == ""} {1538 set file .1539 } else {1540 set file [string trim [$box get $select]]1541 }1542 if [file isdirectory [file join [set ${filvar}(dir)] $file]] {1543 if {$file == ".."} {1544 set ${filvar}(dir) [file dirname [set ${filvar}(dir)] ]1545 } elseif {$file != "."} {1546 set ${filvar}(dir) [file join [set ${filvar}(dir)] $file]1547 }1548 [set ${filvar}(FileDirButtonMenu)] delete 0 end1549 set list ""1550 set dir ""1551 foreach subdir [file split [set ${filvar}(dir)]] {1552 set dir [file join $dir $subdir]1553 lappend list $dir1554 }1555 foreach path $list {1556 [set ${filvar}(FileDirButtonMenu)] add command -label $path \1557 -command "[list set ${filvar}(dir) $path]; \1558 unixFilChoose $frm $box $filvar $dironly"1559 }1560 set ${filvar}(name) {}1561 $box delete 0 end1562 $box insert end {.. }1563 foreach file [lsort -dictionary [glob -nocomplain \1564 [file join [set ${filvar}(dir)] *] ] ] {1565 if {[file isdirectory $file]} {1566 # is this / needed here? Does it cause a problem in MacGSAS?1567 $box insert end [file tail $file]/1568 } elseif {$dironly == 1} {1569 $box insert end [file tail $file]1570 } elseif {$dironly == 2 && [file extension $file] == ".EXP"} {1571 $box insert end [file tail $file]1572 }1573 }1574 return1575 }1576 set ${filvar}(name) [file tail $file]1577 }1578 1579 # set new file name from old -- used for convunix1580 proc setoutfile {} {1581 global infile outfile1582 if {$outfile(type) == "convstod"} {1583 set lfile [string toupper $infile(name)]1584 } elseif {$outfile(type) == "convdtos"} {1585 set lfile [string tolower $infile(name)]1586 } else {1587 set lfile ""1588 }1589 if {$infile(name) == $lfile} {1590 set outfile(name) {}1591 } else {1592 set outfile(name) $lfile1593 }1594 }1595 1596 #------------------------------------------------------------------------------1597 # file conversions for Windows1598 #------------------------------------------------------------------------------1599 proc convwin {} {1600 1394 global expgui 1601 1395 set frm .file … … 1649 1443 set file [file join $expgui(FileMenuDir) $expgui(FileMenuCnvName)] 1650 1444 if ![file exists $file] { 1651 tk_dialog .warn"Convert Error" \1652 "File $file does not exist" question 0 "OK"1445 MyMessageBox -parent $frm -title "Convert Error" \ 1446 -message "File $file does not exist" -icon error 1653 1447 return 1654 1448 } … … 1668 1462 set in [open $file r] 1669 1463 set out [open $tmpname w] 1464 fconfigure $out -translation crlf 1670 1465 set len [gets $in line] 1671 1466 if {$len > 160} { … … 1692 1487 file rename -force $tmpname $file 1693 1488 } errmsg] { 1694 tk_dialog .warn Notify "Error in conversion:\n$errmsg" warning 0 OK 1489 MyMessageBox -parent $frm -title "Conversion error" \ 1490 -message "Error in conversion:\n$errmsg" -icon warning 1695 1491 } else { 1696 if [tk_dialog .converted Notify \ 1697 "File [file tail $file] converted. (Original saved as [file tail $oldname]).\n\n Convert more files?" \ 1698 "" 0 Yes No] {destroy $frm} 1492 set ans [MyMessageBox -parent $frm -title "More?" \ 1493 -message "File [file tail $file] converted.\n(Original saved as [file tail $oldname]).\n\n Convert more files?" \ 1494 -type yesno -default no] 1495 if {$ans == "no"} {destroy $frm} 1699 1496 } 1700 1497 } … … 1946 1743 # flag files that end in something other than .EXP .exp or .Exp... 1947 1744 if {[string toupper [file extension $expgui(FileMenuEXPNAM)]] != ".EXP"} { 1948 tk_dialog .expFileErrorMsg"File Open Error" \1949 1950 error 0 OK1745 MyMessageBox -parent . -title "File Open Error" \ 1746 -message "File [file tail $expgui(FileMenuEXPNAM)] is not a valid name. Experiment files must end in \".EXP\"" \ 1747 -icon error 1951 1748 return 1952 1749 }
Note: See TracChangeset
for help on using the changeset viewer.