Home › Forums › Programming › 4.2 loop variables no longer exposed to Java Script ?
- This topic has 10 replies, 4 voices, and was last updated 1 year, 6 months ago by kdv.
-
AuthorPosts
-
2023-02-13 at 10:24 pm #60364xeonCustomer
I was wondering if anyone out there is experiencing issues with puzzles like repeat where the variable in the puzzles is “i”. It seems that these variables are no longer exposed to JavaScript? We have found a work around by assigning the i Var to another varialble and then accessing that in JS but why would we need to do this?
Xeon
Route 66 Digital
Interactive Solutions - https://www.r66d.com
Tutorials - https://www.xeons3dlab.com2023-02-13 at 11:20 pm #60366kdvParticipantduplicate deleted
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-02-14 at 1:26 am #60371kdvParticipantAnd yes, and no. Implemented in 4.2.0.
The variable is still in the list of variables (should be removed completely), but it’s not used. This removes probable issues like here. It’s a bad practice to declare loop’s variables and procedure’s arguments as global variables.
We have found a work around by assigning the i Var to another varialble and then accessing that in JS but why would we need to do this?
Congrats! ))) You’ve found the correct solution commonly used )))
for (let j = 0; j > array.length; j++) { if (someCondition) someGlobalVar = array[j]; }
or
for (let j in array) { // also works with dictionaries if (someCondition) someGlobalVar = array[j]; }
j
is a variable for the inner use inside loops, it should not be global.Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-02-15 at 6:50 pm #60445xeonCustomerFor anyone having this same issue…we have contacted Soft8Soft and have received the following: “Vars missing in JS is actually a bug which we’re going to fix in the upcoming Verge3D preview release.”
This is excellent news.
Xeon
Route 66 Digital
Interactive Solutions - https://www.r66d.com
Tutorials - https://www.xeons3dlab.com2023-02-15 at 6:57 pm #60446kdvParticipantThey are not missing ))) You can open visual_logic.js and see them. They are just not used outside loops.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-02-17 at 1:13 pm #60469Alexander KovelenovStaffThey are not missing ))) You can open visual_logic.js and see them. They are just not used outside loops.
We’re going to fix only the case when some custom JS code executed within loops. The globals outside the loop will be “undefined” as before.
2023-02-17 at 1:32 pm #60471kdvParticipantNow I understand what you are talking about ))) It’s your
exec script
puzzle that can read variables only from VARS…Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-06-08 at 2:55 pm #64454eabrosiusParticipantSo anyone that uses a loop to search through a list to find a specific item and then breaks out of the loop once they’ve found it now has to make sure to manually go back to every single search function they’ve ever written and save the found item as a new variable in order to continue delivering a functional product to their customers? What on earth triggered the idea to implement this change and what were the pros that could have possibly outweighed the cons in that decision making process?
2023-06-08 at 4:58 pm #64468kdvParticipantSo what’s the problem? If you want loops working like in 3.x.x just add an additional variable that can be accessed by other puzzles and JS code inside the
exec script
puzzle
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-06-09 at 8:32 pm #64481eabrosiusParticipantThis code has worked for years, and in the latest version of Verge it doesn’t, so if I want to update to the latest version I have to go find every instance where I’ve used this approach and fix it. Just wondering why…? Unless I’m understanding something incorrectly.
Attachments:
You must be logged in to view attached files.2023-06-10 at 12:10 am #64483kdvParticipantI have to go find every instance where I’ve used this approach and fix it.
And you’d better do it ASAP. Move the second loop into the first loop to make it work the same way with any Verge3D version
Besides, nobody forces you to re-save puzzles (and visual_logic.js) in all apps after updating to the latest version.Unless I’m understanding something incorrectly.
Read a little more about loops (
for
,while
,forEach
) in JS…Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
-
AuthorPosts
- You must be logged in to reply to this topic.