

wm withdraw .
if { [llength $argv] > 0 } {
    set file [lindex $argv 0]
} else {
    set file [tk_getOpenFile -filetypes [list [list {symbols files} {.geo}]] \
	    -defaultextension .geo]
    if { $file == "" } { exit }
}

if { ![file exists $file] } {
    tk_messageBox -message "File '$file' does not exist"
    exit
}

set i 1
while 1 {
    set giddir [file join $env(TEMP) gid$i.gid]
    if { ![file exists $giddir] } { break }
    incr i
}

file mkdir $giddir
file copy $file [file join $giddir [file root [file tail $giddir]].geo]
exec "/gid project/gid.exe" [file native $giddir]
update
set fileout [tk_getSaveFile -filetypes [list [list {symbols files} {.geo}]] \
	-defaultextension .geo -initialdir [file dirname $file] -initialfile [file tail $file]]
if { $fileout == "" } { exit }

if { [file exists $fileout] } {
    file rename $fileout $fileout~
}
file copy -force [file join $giddir [file root [file tail $giddir]].geo] $fileout

