HISE Logo Forum
    • Categories
    • Register
    • Login

    Initialize value at init?

    Scheduled Pinned Locked Moved Scripting
    4 Posts 2 Posters 296 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dan KorneffD
      Dan Korneff
      last edited by

      What's the proper way to initialize a variable to the value of a parameter?
      I'm trying this, which works, when when I restart HISE, the value is always 0

      const var Knob1 = Content.getComponent("Knob1");
      
      var initializedValue = Knob1.getValue();
      

      Dan Korneff - Producer / Mixer / Audio Nerd

      ulrikU 1 Reply Last reply Reply Quote 0
      • ulrikU
        ulrik @Dan Korneff
        last edited by

        @Dan-Korneff are you giving the variable the value inside a callback?

        Hise Develop branch
        MacOs 15.3.1, Xcode 16.2
        http://musikboden.se

        Dan KorneffD 1 Reply Last reply Reply Quote 0
        • Dan KorneffD
          Dan Korneff @ulrik
          last edited by Dan Korneff

          @ulrik I'm not. I'm trying to set this variable at init so I can reference it in the Knob1 callback.

          Dan Korneff - Producer / Mixer / Audio Nerd

          Dan KorneffD 1 Reply Last reply Reply Quote 0
          • Dan KorneffD
            Dan Korneff @Dan Korneff
            last edited by

            Got a working solution. Just declare the variable as undefined, and then use an if statement in the knob callback to define if == undfined

            Dan Korneff - Producer / Mixer / Audio Nerd

            1 Reply Last reply Reply Quote 2
            • First post
              Last post

            37

            Online

            1.8k

            Users

            12.0k

            Topics

            104.1k

            Posts