JavaScript problem
JavaScript makes me mad.
When I click on "Undo" (my custom button). The following goes in the process. And anything written as For(...){ ...} give me the error
"} bracket is missing" refer to the attachment
var pointsNb=ggbApplet.getValue("pointsNb");
for(var ti=0;ti<=pointsNb;ti++)
{
ggbApplet.evalCommand("DeleteObject(P"+String(ti)+")");
}
too, even if I make a simple one
...
for(var ti=0;ti<=pointsNb;ti++)
{
ti=ti+1;
}
Note: this configuration or similar loop I made in another button, no error is generated.
Something illogical.
look to this:
var pointsNb=ggbApplet.getValue("pointsNb");
for (var ti=0;ti<=pointsNb;ti++)
{
v2x=(-k*v1x*Math.sqrt(Math.pow(v1x,2)+Math.pow(v1y,2)))*dt+v1x;
v2y=(-k*v1y*Math.sqrt(Math.pow(v1x,2)+Math.pow(v1y,2))-g)*dt+v1y;
....
...
}
It works properly.
Please always post your .ggb file
Upload it you mean? OK
Here it is
But since no space to work with Javascript as other editors, I am not explaining in the.
Can we write our JavaScript in an editor, let to say notepad or JavaEdito or any, and upload it by Geogebra script?
Maybe we should add it as a package or import? So this can help me to more organize my program
Using a list in GeoGebra (and then eg Sequence()) will be much better than doing this in JavaScript
My question above is solved as:
var pointsNb=ggbApplet.getValue("pointsNb");
for(var ti=0;ti<=pointsNb;ti++)
{
ggbApplet.evalCommand("Delete(P"+String(ti)+")");
}
You can mark my question as answered
Comments have been locked on this page!