Properties
Category
German
Similar Topics
Statistics
Comments
12
Participants
3
Subscribers
3
Votes
1
Views
53
Share
Answered
The javascript command getAllObjectNames is marked as depreceated since 3.0.
What should I use instead? Will the command be removed in future?
Regards
Wolfgang
- GeoGebra
- Help
- Partners
-
Contact us
- Feedback & Questions
- This email address is being protected from spambots. You need JavaScript enabled to view it.
- +43 677 6137 2693
© 2019 International GeoGebra Institute
use for()
attached a Sample
Hi,
thank's for your answer ..... but in yout button "kontolle", you have the code
// get the list of objects out of GGB
let allGgbObjects = ggbApplet.getAllObjectNames();
That was exactly my question ... This command is depreceated. How should we replace it?
Regards
Wolfgang
Sorry,
I have no button "kontrolle" and I have not the comment "// get the list of objects out of GGB"
and last but not least, I'm not using the command "ggbApplet.getAllObjectNames();"
Maybe you got the file mixed up.
check also the date of the file and if it exists the index (for example (2))
Hi,
you're right. Got the wrong file - sorry.
As far as I see, you just loop with i++, ignoring the number of existing Objects.
g = ggbApplet
nam = new Array()
for (i = 0; i < g.getObjectNumber(); i++) {
nam.push("" + g.getObjectName(i))
}
That means, the error of "array index out of bounds" or sim. is handled inside Geogebra automatically.
From one side ... very comfortable, from the other ... too much "magic" :)
Thank you
Regards
Wolfgang
Ich denke wir können auch auf Deutsch fortfahren:
Warum sollte ein Fehler von der Art "array index out of bounds" auftreten? Und was ist "sim".
Die Anzahl der vorhandenen Objekte ist mit "g.getObjectNumber()" innerhalb der for-Anweisung berücksichtigt.
Nein, ich denke in diesem kleinen loop macht GGB resp. JS nichts automatisch resp. im Verborgenen und schon gar nichts magisches.
Let's make it simple, getAllObjectNames() is now "un-deprecated" :)
(now that we no longer have the old Java applets)
Klar, können wir :smile:
(sim hab ich als Abkürzung für "similar", also o.ä. verwendet).
Du hast (leider) schon wieder Recht :smile: . Ich hab auf die Schnelle übersehen, dass du dir vorher die Anzahl der vorhandenen Elemente in der Konstruktion geholt hast. Dann ist es unproblematisch. Ich hab auf den ersten Blick gedacht, du erhöhst einfach nur immer weiter den Index, bis Geogebra sagt, dass es keine Elemente mehr gibt ...
Allerdings finde ich die Methode trotzdem etwas einschränkend, da man anscheinend nicht alle Objekte eines bestimmten Typs abrufen kann. Hier muss man dann nachgelagert im Javascript filtern, falls man nur die Kreise, Punkte, ... o.ä. haben möchte. Ich fand das vorher gar nicht schlecht ....
VG
Wolfgang
Nachgelagert?
Das ginge auch innerhalb des loop wie folgt (ungetestet):
if(g.getObjectType(g.getObjectName(i)) == "point") {nam.push("" + g.getObjectName(i))}
.
Aber dessen ungeachtet: es ist gut zu hören, dass getAllObjectNames() nach wie vor und auch in Zukunft verwendet werden kann.
But anyway, it's good to hear that getAllObjectNames() can still be used and will continue to be used.
Damit ist es für mich nachgelagert, weil ich mir aus allen Ergebnissen selber die raussuchen muss, die ich haben will. Ist wie beim Einkaufen :) Da sag ich an der Theke ja auch, "Ich will Würstel" und nicht "Geben Sie mir alles was sie haben, ich such mir die Würstel dann raus ..." :)
Aber klar kann man das so lösen.
Einverstanden.
Aber...wie wärs mit "geben sie mir bitte das nächste Würstel"
(vorsicht Glatteis)
Ja, das wäre aber dann eher das Konstrukt
while (akt.hasNext()){
akt = obj.next()
push ...
}
Aber viele Wege führen nach Rom ...
Comments have been locked on this page!