I can't seem to find a way to do this. Basically I want to do this in pseudocode:
MainScript.fsx:
printfn "starting an external script"
launch Script1.fsx
printfn "Finished"
Script1.fsx:
printfn "I am Script1 running"
So the output window should show (a开发者_如何学Cfter running MainScript.fsx):
"starting an external script"
"I am Script1 running"
"Finished"
Basically the launch Script1.fsx is the method I don't know how to implement.
Thanks in advance,
Bob
You can use ProcessStartInfo
to start a new process. You need to give the path to fsi.exe, and use your fsx file as an argument. You need to set UseShellExecute
to false to have the result in your interactive shell.
For example:
let exec fsi script =
let psi = new System.Diagnostics.ProcessStartInfo(fsi)
psi.Arguments <- script
psi.UseShellExecute <- false
let p = System.Diagnostics.Process.Start(psi)
p.WaitForExit()
p.ExitCode
exec @"c:\Program Files\Microsoft F#\v4.0\Fsi.exe" "foo.fsx"
精彩评论