Error: No callback given (argument #0)

22 views
Skip to first unread message

Josh Gates

unread,
Jul 28, 2017, 10:04:16 AM7/28/17
to Glowscript Users
I'm trying to run a calculation and graph the results, with a slider to select the size of a parameter and a button to re-run it. The basic loop that does the calculation and graphing runs fine. When I put that into a function and attach it to a button, though, it doesn't run and I get the error above. This is in Trinket: https://trinket.io/glowscript/e99c51c5c3

After this works, I'm not sure exactly what I'll do to clear the previous graphs for the next time through, either.

Thanks!
Josh 

Bruce Sherwood

unread,
Jul 28, 2017, 10:31:50 AM7/28/17
to Glowscript Users
Alas, rate and waitfor statements cannot be inside functions. In your case a fix is trivial: delete the rate(1000) statement. Another approach is to put the function content inside your while loop, executed when a global variable has been set to True in a button function. Yet another approach is to write your code in an "asynchronous" style. See for example this:


As for graph deletion, here's the graph documentation (but I think this capability may have been added later than version 2.1):

Deleting data or an entire graph

If you create a gcurve, gdots, gvbars, or ghbars entity and name it g, you can delete the associated data from a graph by saying g.delete(). Similarly, if you say gd = graph(), you can delete the entire graph by saying gd.delete().

Bruce Sherwood

unread,
Jul 28, 2017, 10:35:45 AM7/28/17
to Glowscript Users
Actually, graph deletion options do seem to be available in version 2.1.

Josh Gates

unread,
Jul 28, 2017, 10:36:59 AM7/28/17
to glowscri...@googlegroups.com
Yes - they worked great, as did the rate removal. Thanks for the help!

jg

On Fri, Jul 28, 2017 at 10:35 AM, Bruce Sherwood <bruce.s...@gmail.com> wrote:
Actually, graph deletion options do seem to be available in version 2.1.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Glowscript Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/glowscript-users/iJBM9JgwShU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to glowscript-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Joshua Gates

Reply all
Reply to author
Forward
0 new messages