Hi!
There are some confusion caused primarily by giving script itself and a function inside this script the same name. In "use" operator you should use script name (you can think of it as of virtual file name) - the one you see in script list in the library. Then, you can call functions from that script using their respective names - name of the function may or may not be identical to script name. Note that each script has it's own main() function, even if you do not declare it explicitly, so you cannot call main() function of another script. One script may provide multiple functions, like in this example:
Script in the library called "MyScript":
and then you use it in some other script:
Script above will produce output
Best regards,
Victor
There are some confusion caused primarily by giving script itself and a function inside this script the same name. In "use" operator you should use script name (you can think of it as of virtual file name) - the one you see in script list in the library. Then, you can call functions from that script using their respective names - name of the function may or may not be identical to script name. Note that each script has it's own main() function, even if you do not declare it explicitly, so you cannot call main() function of another script. One script may provide multiple functions, like in this example:
Script in the library called "MyScript":
Code Select
/* function 1 */
sub f1(p)
{
println "f1 called with parameter " . p;
}
/* function 2 */
sub f2(p)
{
println "f2 called with parameter " . p;
}
and then you use it in some other script:
Code Select
use MyScript; /* load script from library by it's name */
f1(1); /* call function f1 */
f2(2); /* call function f2 */
Script above will produce output
Code Select
f1 called with parameter 1
f2 called with parameter 2
Best regards,
Victor
