We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

4.2 loop variables no longer exposed to Java Script ?

Home Forums Programming 4.2 loop variables no longer exposed to Java Script ?

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #60364
    xeon
    Customer

    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.com

    #60366
    kdv
    Participant

    duplicate 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.

    #60371
    kdv
    Participant

    And 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.

    #60445
    xeon
    Customer

    For 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.com

    #60446
    kdv
    Participant

    They 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.

    #60469

    They 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.

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #60471
    kdv
    Participant

    Now 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.

    #64454
    eabrosius
    Participant

    So 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?

    #64468
    kdv
    Participant

    So 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.

    #64481
    eabrosius
    Participant

    This 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.
    #64483
    kdv
    Participant

    I 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.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.