As I said in previous responses, JavaScript and Scripts are not the same thing - they do not interact in any way, shape or form.
However, you’re not completely out of luck. You can’t “include” a Script inside another, however you can define variables and functions globally, so they can be accessed in other scripts processed after it.
For example, very simple hello world function placed inside a first script with the body selector:
hello_world = function(name) { // Note the missing var keyword! This makes it global…
return "Hello, " + name;
};
Then, a second script on a paragraph, say p.hellomessage:
results.html(hello_world(“mike”));
This diplays “Hello, mike” in the paragraph with the class “hellomessage”. Both variables and functions can be declared globally like this, so if you create a Script with your function definitions and contants, you’ll be fine. However, there’s currenly no way to export and import scripts so you’ll have to use copy/paste…
That sounds good - but as we are just starting to understand what can be done where and how - could you provide a demo “OL-template” - file that demonstrates that?
That would be really great!
Thanks for your quick answers.
The sample is very simple and doesn’t contain any design or static elements. Go to the Preview tab to see the result of the script, which prints “Hello, Mike, and welcome to Globadyne, Inc.”
Both the hello_world() function and the COMPANY_NAME variable are defined in the first script, and used in the second script, demonstrating that they are, indeed, global.
You must be looking at something else - there is no such file on the demo server, at least not in the public files. Are you sure you didn’t download it to a different location? It works fine for me…