GeoGebra JavaScript stops after some loops

r.hoh shared this question 3 weeks ago
Answered

Hi,

I wrote a GG-Applet which two JavaScrips:

1: GG erzeugen

This Script generate a list of 2000 numbers where the number 0 ist randomly distributed according to the slider-value "a".

No problem with this part.


2. VI berechnen

This script first take a sample of 200 out of the above list and then calculates the confidence interval.

The confidence interval is visualised with a lower "U" and upper "O" point and a connecting segment.


Alltogether 100 CI´s are calculated in two nested loops.


Problem:

This script runs a few times and then aborts without any error-message.

I then Have to use the task-manager to close GeoGebra.


Any idea or hint why this happens and a possible solution would be appreciated.


Ralf

Comments (3)

photo
1

1) have you tried using alert() to find why/where the script is getting stuck?

2) You should rework it to avoid using "=" as that reloads the whole construction each time, eg

    ggbApplet.evalCommand("U" + i + "=(" + i + "," + pu + ")")
So try and reuse objects rather than deleting/recreating them. You can use setValue() and setCoords() for this


3) Even better - avoid JavaScript and use eg Sequence()

photo
1

Thanks Michael,


I´m afraid that doens´t work.

I did as you suggested (using setCoords to change the coodinates of the already existing points rather then creating new ones), but the same problem occurs.


It is somewhat strange that the script works a couple times and then it doens´t.


Ralf

photo
1

You still have "=" here:


ggbApplet.evalCommand("b=Segment((0,a),(100,a))")


Did you try (1)?

© 2020 International GeoGebra Institute