Changeset 360
- Timestamp:
- Dec 4, 2009 5:04:52 PM (11 years ago)
- 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 1234 1234 #------------------------------------------------------------------------------ 1235 1235 # run a GSAS program that does not require an experiment file 1236 proc runGSASprog {proglist} { 1236 proc 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. 1237 1239 global expgui tcl_platform 1238 1240 set cmd {} … … 1245 1247 } 1246 1248 } 1247 forknewterm $prog $cmd 0 111249 forknewterm $prog $cmd [expr !$concurrent] 1 1248 1250 } 1249 1251 1250 1252 # run a GSAS program that requires an experiment file for input/output 1251 1253 proc runGSASwEXP {proglist "concurrent 0"} { 1254 # most programs that require the .EXP file change it and 1255 # cannot be run concurrently 1252 1256 global expgui tcl_platform 1253 1257 # Save the current exp file … … 1269 1273 } 1270 1274 } 1271 forknewterm "$prog -- $expnam" $cmd $concurrent 111275 forknewterm "$prog -- $expnam" $cmd [expr !$concurrent] 1 1272 1276 # load the changed .EXP file automatically? 1273 1277 if {$expgui(autoexpload)} { … … 2158 2162 # platform-specific definitions 2159 2163 if {$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 } 2160 2178 # this creates a DOS box to run a program in 2161 proc forknewterm {title command " background 0" "scrollbar 1" "wait1"} {2179 proc forknewterm {title command "wait 1" "scrollbar 1"} { 2162 2180 global env expgui 2163 2181 # Windows environment variables 2164 # -95 does not seem to be able to use these2165 2182 set env(GSAS) [file nativename $expgui(gsasdir)] 2166 2183 # PGPLOT_FONT is needed by PGPLOT … … 2170 2187 set pwd [file nativename [pwd]] 2171 2188 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]] 2172 2252 # check the path -- can DOS use it? 2173 2253 if {[string first // [pwd]] != -1} { … … 2178 2258 return 2179 2259 } 2180 # all winexec commands are background commands2181 # if $background2182 2183 2260 # 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 } 2217 2286 } 2218 2287 } 2219 2288 } else { 2220 2289 # this creates a xterm window to run a program in 2221 proc forknewterm {title command " background 0" "scrollbar 1" "wait1"} {2290 proc forknewterm {title command "wait 1" "scrollbar 1"} { 2222 2291 global env expgui 2223 2292 # UNIX environment variables … … 2239 2308 append termopts " +sb" 2240 2309 } 2241 if $background { 2310 if {$wait} { 2311 set suffix {} 2312 } else { 2242 2313 set suffix {&} 2243 } else {2244 set suffix {}2245 2314 } 2246 2315 # 2247 if $wait{2316 #if $wait { 2248 2317 append command "\; echo -n Press Enter to continue \; read x" 2249 }2250 if !$background{wm iconify .}2318 #} 2319 if {$wait && $expgui(autoiconify)} {wm iconify .} 2251 2320 catch {eval exec xterm $termopts -title [list $title] \ 2252 2321 -e /bin/sh -c [list $command] $suffix} errmsg 2253 2322 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.