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.

Exec Text variables and scope use window.var or VARS?

Home Forums Puzzles Exec Text variables and scope use window.var or VARS?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #33416
    GlifTekGlifTek
    Licensee

    Hi,
    I’ve been putting a large amount of code from the clipping planes example project into separate exec text puzzles to get it more organized, controllable, and able to be used more flexibly and dynamically with my larger project.

    I know the variables in them are available from within them like function scope, so I’m trying to find ready ways to make them available to others when needed…

    One way was to have the first exec text in the stack be an initializer and instead of using “var myVar”, be window.myVar for each one…

    I’ve read that if your var names aren’t unique enough, then using window could mess with other browser based variables.

    Would this be an issue?

    Another way is just hand their values of to VARS[‘myVar’] in one exec puzzle, and then back again in the next.

    Or wrap them in procedures with inputs and returns to chain them.

    What’s the best way? Is there any other? Thanks!

    #33444
    Yuri KovelenovYuri Kovelenov
    Developer

    IMHO, VARS is better since it uses an internal namespace rather than global one.

    3D Verger, the CEO
    LinkedIn | FB | Twitter | VK | 新浪微博

    #33459
    GlifTekGlifTek
    Licensee

    IMHO, VARS is better since it uses an internal namespace rather than global one.

    I just put two large text areas together with a combine text puzzle into an exec thought I shared variables between execs. nope. Hah

    #33478
    Yuri KovelenovYuri Kovelenov
    Developer

    two large text areas together with a combine text puzzle into an exec

    This just creates a big chunk of text to be interpreted as code. I think this should work.

    3D Verger, the CEO
    LinkedIn | FB | Twitter | VK | 新浪微博

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