Regarding transferring data from a NetLogo applet out into the rest of
the browser, you'll want to use the LiveConnect
<https://jdk6.java.net/plugin2/liveconnect/> functionality, which allows
Java and JavaScript to talk to one another.
Here's some example JavaScript for alerting the user of the value of
`count turtles`, as pulled from a NetLogo applet whose `applet` tag has
`id="netlogo-applet"`:
```
var nlPanel = null;
var nlReport = function(code) {
return nlPanel.report(code);
};
var count = function() {
try {
alert(nlReport("count turtles"));
} catch(e) {
console.log(e);
}
};
var initializeNLPanel = function() {
try {
var panel = document.getElementById("netlogo-applet").panel(); //
org.nlogo.lite.Applet object
if (panel === undefined || panel === null) {
throw "Failed to get panel";
} else {
nlPanel = panel;
}
} catch (e) {
window.setTimeout(initializeNLPanel, 250);
}
};
initializeNLPanel();
count();
```
I wouldn't be surprised if there are some issues with binding `this` in
my code above, given that I pulled this example out from something that
I wrote here
<https://github.com/WISE-Community/WISE-VLE/blob/master/src/main/webapp/vle/node/netlogo/netlogo.js>,
but, at the very least, the gist of what needs to be done is in the
above code. Pass whatever NetLogo code you want the value of---`count
turtles`, `1 + 1`, the name of the variable tied to some interface
widget in your model---into `nlReport`, and you should get the value back.
Jason Bertsche
Senior Software Developer - NetLogo
On 01/20/2014 10:34 AM, Ifigenia Koutiva wrote:
I am also trying to see whether it is possible for a web user to
export data from an output window in the gui layout. If this is not
possible is there any other way for a web user to export results from
an applet?
--
You received this message because you are subscribed to the Google Groups
"netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.