如何阅读命令行争论 [英] How to read command line arguements
问题描述
我在某处找到了此代码(我丢失了URL),我想使其同时适用于fsi.exe和fsc.exe.对于fsi.exe,它似乎工作正常.我也该如何为fsc.exe工作?
I found this code somewhere (I lost the URL) and I would like to make it work for both fsi.exe and fsc.exe. It seems to work OK for fsi.exe. How can I make to work for fsc.exe too?
let argv =
#if INTERACTIVE
fsi.CommandLineArgs
#else
Sys.argv
#endif
当我尝试编译fsc.exe时,我不断收到错误消息.这个神奇的数组Sys.argv在哪里定义?
I keep getting errors from fsc.exe when I try to compile it. Where is this magical array Sys.argv defined?
还:fsi是否有一个命令行参数,它将使它执行扩展名为.fs的文件,还是我必须将其重命名为扩展名为.fsx的文件?
Also: is there a command line argument for fsi that will make it execute a file with the extension of .fs or do I have to rename it to have an extension of .fsx?
siegfried heintze
siegfried heintze
推荐答案
以下代码对我有用读取fsc.exe的命令行参数.
The following code worked for me to read the command lines argument for fsc.exe.
let ary = System.Environment.GetCommandLineArgs()
Array.iter (printf "%s ") ary
您还可以检查此链接,该链接详细说明了您的问题.
You may also check this link which explains in detail for your question.
这篇关于如何阅读命令行争论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!