Starfinder Playlist
  1. #1

    Calling WindowControls As Strings

    Hi Guys,

    Quick question: if I pass a variable (eg sPath="window.subwindow01.subwindow.number01") to a function (eg fpMyFunction(sPath,nValue)) what is the correct syntax for the following:

    Code:
    function fpMyFunction(sPath,nValue)
        sPath.setValue(nValue);
    end
    Where I'm trying to set window.subwindow01.subwindow.number01.setValue(nVa lue)?

    Cheers
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    In your example, sPath is a variable that contains the complete control reference name, whereas you need the control object to be able to use API methods against the control. I'm not aware of a method that will allow you to get to the control object using the complete control reference name. To make this work, pass the control object reference to the function, not the control name then you can use .setValue directly against the object.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    Quote Originally Posted by Trenloe View Post
    In your example, sPath is a variable that contains the complete control reference name, whereas you need the control object to be able to use API methods against the control. I'm not aware of a method that will allow you to get to the control object using the complete control reference name. To make this work, pass the control object reference to the function, not the control name then you can use .setValue directly against the object.
    OK, so using my example as a starting point, what would be the control reference to the control window.subwindow01.subwindow.number01?

    For eg: do I set sPath = window.subwindow01.subwindow.number01 (as opposed to sPath = "window.subwindow01.subwindow.number01")?
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    Quote Originally Posted by dulux-oz View Post
    For eg: do I set sPath = window.subwindow01.subwindow.number01 (as opposed to sPath = "window.subwindow01.subwindow.number01")?
    Yes, but you'd need to reference that within a script where the window variable is pointing to the correct window - within a script tied to a control this will be pointing to the window the control resides in, but if you are referencing this within a global script package it won't know what window is and you'll have to either pass/register the window variable in the global script package.

    See "Script block scope" here: https://www.fantasygrounds.com/modguide/scripting.xcp
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  5. #5
    Ok, thanks Tren, I think I've got it sorted now
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in