如何加载外部 F# 脚本文件并在 F# 交互中使用它? [英] How to load external F# script file and use it in F# interactive?
问题描述
我想将一个或多个 .fsx
文件加载到 F# 交互中,并在范围内定义 .fsx
文件中定义的所有函数,以便我可以直接使用控制台中的函数.
I would like to load one or more .fsx
files into the F# interactive and have all the functions defined in the .fsx
files in scope so that I can directly use the functions in the console.
#load
指令执行指定的 .fsx
文件,但随后我无法再在 .fsx
中使用这些函数文件.有什么解决方法吗?谢谢.
The #load
directive executes the .fsx
file specified, but then I am no longer able to use those functions in the .fsx
file. Any workaround for this? Thanks.
推荐答案
我怀疑您正在加载的脚本不在可能导致您出现问题的模块中.只需添加
I suspect that the script you are loading is not in a module which may be causing your problem. Just add
module Script1
在第一个脚本中然后你可以做
in the first script and then you can do
#load "Script1.fsx"
open Script1
并且您的功能将可以访问
and your functions will be accessible
这篇关于如何加载外部 F# 脚本文件并在 F# 交互中使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!