2,732
edits
Red Leader (talk | contribs) (→close(): It also flushes the buffer) |
Red Leader (talk | contribs) (→load_nasal(): Add examples) |
||
Line 89: | Line 89: | ||
|param2 = module | |param2 = module | ||
|param2text = Optional name of module to load the script into as a string. If not given, the namespace will be the name of the file. | |param2text = Optional name of module to load the script into as a string. If not given, the namespace will be the name of the file. | ||
|example1 = | |example1text = For the examples, first put the below code in to a new file, <tt>''[[$FG_HOME]]/Export/demo.nas''</tt>: | ||
<syntaxhighlight lang="nasal"> | |||
var sayHello = func(){ | |||
print("Hello, World!"); | |||
} | |||
</syntaxhighlight> | |||
|example1 = var file = getprop("/sim/fg-home") ~ '/Export/demo.nas'; | |||
io.load_nasal(file); # load into "demo" namespace | |||
demo.sayHello(); # "Hello, World!" will be printed | |||
|example2 = var file = getprop("/sim/fg-home") ~ '/Export/demo.nas'; | |||
io.load_nasal(file, "myDemo"); # load into "myDemo" namespace | |||
myDemo.sayHello(); # "Hello, World!" will be printed | |||
}} | }} | ||