Changeset 360


Ignore:
Timestamp:
Dec 4, 2009 5:04:52 PM (11 years ago)
Author:
toby
Message:

# on 2000/12/22 19:44:07, toby did:
Major reworking of routines to run GSAS routines:

non-EXP using programs run independently by default
Pause is now hard-coded
EXP using programs run in foreground by default (exception is POWPLOT)

Win-95 implementation of forknewterm rewritten to loop over commands

& use lock file (resume when lock file is deleted) & have "lock" window

Win-NT revised to not use WINEXEC & run in foreground
UNIX implementation of forknewterm revised to match previous

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsascmds.tcl

    • Property rcs:date changed from 2000/10/18 00:03:58 to 2000/12/22 19:44:07
    • Property rcs:lines changed from +1187 -1173 to +109 -40
    • Property rcs:rev changed from 1.27 to 1.28
    r328 r360  
    12341234#------------------------------------------------------------------------------
    12351235# run a GSAS program that does not require an experiment file
    1236 proc runGSASprog {proglist} {
     1236proc runGSASprog {proglist "concurrent 1"} {
     1237    # if concurrent is 0, EXPGUI runs the GSAS program in background
     1238    # -- this is not currently needed anywhere where the .EXP file is not.
    12371239    global expgui tcl_platform
    12381240    set cmd {}
     
    12451247        }
    12461248    }
    1247     forknewterm $prog $cmd 0 1 1
     1249    forknewterm $prog $cmd [expr !$concurrent] 1
    12481250}
    12491251
    12501252# run a GSAS program that requires an experiment file for input/output
    12511253proc runGSASwEXP {proglist "concurrent 0"} {
     1254    # most programs that require the .EXP file change it and
     1255    # cannot be run concurrently
    12521256    global expgui tcl_platform
    12531257    # Save the current exp file
     
    12691273        }
    12701274    }
    1271     forknewterm "$prog -- $expnam" $cmd $concurrent 1 1
     1275    forknewterm "$prog -- $expnam" $cmd [expr !$concurrent] 1
    12721276    # load the changed .EXP file automatically?
    12731277    if {$expgui(autoexpload)} {
     
    21582162# platform-specific definitions
    21592163if {$tcl_platform(platform) == "windows" && $tcl_platform(os) == "Windows 95"} {
     2164    # windows-95, -98 and presumably -me do not allow Tcl/Tk to run the
     2165    # DOS box synchronously, so we create a "lock" file that is deleted
     2166    # at the end of the DOS run so we can tell when the run is done.
     2167    # We create a window to force the deleting of the file so that if
     2168    # the DOS process crashes, the user can continue anyway.
     2169    #
     2170    # procedure to check if the lock file is still there (Win-9x/me only)
     2171    proc checklockfile {file window} {
     2172        if [file exists $file] {
     2173            after 500 checklockfile $file $window
     2174        } else {
     2175            catch {destroy $window}
     2176        }
     2177    }
    21602178    # this creates a DOS box to run a program in
    2161     proc forknewterm {title command "background 0" "scrollbar 1" "wait 1"} {
     2179    proc forknewterm {title command "wait 1" "scrollbar 1"} {
    21622180        global env expgui
    21632181        # Windows environment variables
    2164         # -95 does not seem to be able to use these
    21652182        set env(GSAS) [file nativename $expgui(gsasdir)]
    21662183        # PGPLOT_FONT is needed by PGPLOT
     
    21702187        set pwd [file nativename [pwd]]
    21712188       
     2189        # check the .EXP path -- can DOS use it?
     2190        if {[string first // [pwd]] != -1} {
     2191            MyMessageBox -parent . -title "Invalid Path" \
     2192                    -message {Error -- Use "Map network drive" to access this directory with a letter (e.g. F:) GSAS can't directly access a network drive} \
     2193                    -icon error -type ok -default ok \
     2194                    -helplink "expgui_Win_readme.html NetPath"
     2195            return
     2196        }
     2197        # pause is hard coded in the .BAT file
     2198        #
     2199        # loop over multiple commands
     2200        foreach cmd $command {
     2201            # simulate the wait with a lock file
     2202            if {$wait} {
     2203                if {$expgui(autoiconify)} {wm iconify .}
     2204                # create a blank lock file and a message window
     2205                close [open expgui.lck w]
     2206                toplevel .lock
     2207                grid [button .lock.0 -text Help -bg yellow \
     2208                        -command "MakeWWWHelp expguierr.html lock"] \
     2209                        -column 1 -row 0
     2210                grid [label .lock.1 \
     2211                        -text "Please wait while the GSAS program finishes."] \
     2212                        -column 0 -row 0
     2213                grid [label .lock.2 -text \
     2214                        "In case a problem occurs, close the DOS box"] \
     2215                        -column 0 -columnspan 2 -row 1
     2216                grid [label .lock.3 -text \
     2217                        "and press the \"Continue\" button (below)"] \
     2218                        -column 0 -columnspan 2 -row 2
     2219                grid [button .lock.b -text "Continue" \
     2220                        -command "destroy .lock; wm deiconify ."] \
     2221                        -column 0 -columnspan 2 -row 3
     2222                putontop .lock
     2223                update
     2224                checklockfile expgui.lck .lock
     2225            }
     2226            # replace the forward slashes with backward
     2227            regsub -all / $cmd \\ cmd
     2228            winexec -d [file nativename [pwd]] \
     2229                    [file join $expgui(scriptdir) gsastcl.bat] $cmd
     2230            if {$wait} {
     2231                tkwait window .lock
     2232                file delete -force expgui.lck
     2233            }
     2234        }
     2235        if {$expgui(autoiconify) && $wait} {wm deiconify .}
     2236        # check for changes in the .EXP file immediately
     2237        whenidle
     2238    }
     2239} elseif {$tcl_platform(platform) == "windows"} {
     2240    # now for Windows-NT, where we can run synchronously
     2241    #
     2242    # this creates a DOS box to run a program in
     2243    proc forknewterm {title command  "wait 1" "scrollbar 1"} {
     2244        global env expgui
     2245        # Windows environment variables
     2246        set env(GSAS) [file nativename $expgui(gsasdir)]
     2247        # PGPLOT_FONT is needed by PGPLOT
     2248        set env(PGPLOT_FONT) [file nativename [file join $expgui(gsasdir) fonts grfont.dat]]
     2249        # this is the number of lines/page in the .LST (etc.) file
     2250        set env(LENPAGE) 60
     2251        set pwd [file nativename [pwd]]
    21722252        # check the path -- can DOS use it?
    21732253        if {[string first // [pwd]] != -1} {
     
    21782258            return
    21792259        }
    2180         # all winexec commands are background commands
    2181         #       if $background
    2182        
    21832260        # pause is hard coded in the .BAT file
    2184            
    2185         # replace the forward slashes with backward
    2186         regsub -all / $command \\ command
    2187         # Win95 does not seem to inherit the environment from Tcl env vars
    2188         # so define it in the .BAT file
    2189         winexec -d [file nativename [pwd]] \
    2190                 [file join $expgui(scriptdir) gsastcl.bat] \
    2191                 "[file nativename $expgui(gsasdir)] $command"
    2192     }
    2193 } elseif {$tcl_platform(platform) == "windows"} {
    2194     # now for - brain-dead Windows-NT
    2195     # this creates a DOS box to run a program in
    2196     proc forknewterm {title command "background 0" "scrollbar 1" "wait 1"} {
    2197         global env expgui
    2198         # Windows environment variables
    2199         set env(GSAS) [file nativename $expgui(gsasdir)]
    2200         # PGPLOT_FONT is needed by PGPLOT
    2201         set env(PGPLOT_FONT) [file nativename [file join $expgui(gsasdir) fonts grfont.dat]]
    2202         # this is the number of lines/page in the .LST (etc.) file
    2203         set env(LENPAGE) 60
    2204         # all winexec commands are background commands -- ignore background arg
    2205         # can't get pause to work! -- ignore wait
    2206        
    2207         set prevcmd {}
    2208         foreach cmd $command {
    2209             if {$prevcmd != ""} {
    2210                 tk_dialog .done_yet Confirm "Press OK to start command $cmd" "" 0 OK
    2211             }
    2212             # replace the forward slashes with backward
    2213             regsub -all / $cmd \\ cmd
    2214             # cmd.exe must be in the path -- lets hope that at least works!
    2215             winexec -d [file nativename [pwd]] cmd.exe "/c $cmd"
    2216             set prevcmd $cmd
     2261
     2262        if {$wait} {
     2263            if {$expgui(autoiconify)} {wm iconify .}
     2264            # create a blank lock file (keep liveplot from running)
     2265            close [open expgui.lck w]
     2266            # loop over commands
     2267            foreach cmd $command {
     2268                # replace the forward slashes with backward
     2269                regsub -all / $cmd \\ cmd
     2270                exec $env(COMSPEC) /c \
     2271                        "start [file join $expgui(scriptdir) gsastcl.bat] $cmd"
     2272            }
     2273            file delete -force expgui.lck
     2274            if {$expgui(autoiconify)} {wm deiconify .}
     2275            # check for changes in the .EXP file immediately
     2276            whenidle
     2277        } else {
     2278            # loop over commands
     2279            foreach cmd $command {
     2280                # replace the forward slashes with backward
     2281                regsub -all / $cmd \\ cmd
     2282                # run in background
     2283                exec $env(COMSPEC) /c \
     2284                        "start [file join $expgui(scriptdir) gsastcl.bat] $cmd" &
     2285            }
    22172286        }
    22182287    }
    22192288} else {
    22202289    # this creates a xterm window to run a program in
    2221     proc forknewterm {title command "background 0" "scrollbar 1" "wait 1"} {
     2290    proc forknewterm {title command "wait 1" "scrollbar 1"} {
    22222291        global env expgui
    22232292        # UNIX environment variables
     
    22392308            append termopts " +sb"
    22402309        }
    2241         if $background {
     2310        if {$wait} {
     2311            set suffix {}
     2312        } else {
    22422313            set suffix {&}
    2243         } else {
    2244             set suffix {}
    22452314        }
    22462315        #
    2247         if $wait {
     2316        #if $wait {
    22482317            append command "\; echo -n Press Enter to continue \; read x"
    2249         }
    2250         if !$background {wm iconify .}
     2318        #}
     2319        if {$wait && $expgui(autoiconify)} {wm iconify .}
    22512320        catch {eval exec xterm $termopts -title [list $title] \
    22522321                -e /bin/sh -c [list $command] $suffix} errmsg
    22532322        if $expgui(debug) {puts "xterm result = $errmsg"}
    2254         if !$background {wm deiconify .}
    2255     }
    2256 }
     2323        if {$wait && $expgui(autoiconify)} {wm deiconify .}
     2324    }
     2325}
Note: See TracChangeset for help on using the changeset viewer.