HISE Logo Forum
    • Categories
    • Register
    • Login

    Can we pass in a function argument to a timer CB?

    Scheduled Pinned Locked Moved General Questions
    5 Posts 3 Posters 297 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.
    • ustkU
      ustk
      last edited by ustk

      I'm trying to find a way to get a function doing something with it's parameter after a delay. Of course, I could have used an external variable, or use a hidden panel timer to benefit from the data object... But in order to keep things tidy and even more for my own knowledge, is it possible to use the parameter from the caller in the timer?

      inline function mainFunctionToCall(myParameter)
      {
      	t.startTimer(1000);
      }
      
      
      const var t = Engine.createTimerObject();
      
      t.setTimerCallback(function()
      {
      	this.stopTimer();
      	// DO SOMETHING WITH myParameter
      });
      

      In the end, as the code suggests, you see that I just want to delay a function call but use its parameter

      Can't help pressing F5 in the forum...

      orangeO 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey
        last edited by

        Can't be done as far as I'm aware

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        1 Reply Last reply Reply Quote 0
        • orangeO
          orange @ustk
          last edited by

          @ustk Maybe this? Here are some snippets.

          Link Preview Image
          Wait for 1 seconds then set the value

          Does anyone know an example with the callWithDelay Broadcaster for this situation?

          favicon

          Forum (forum.hise.audio)

          develop Branch / XCode 13.1
          macOS Monterey / M1 Max

          ustkU 2 Replies Last reply Reply Quote 2
          • ustkU
            ustk @orange
            last edited by

            @orange Youhou! Will be testing this asap! Thanks mate!

            Can't help pressing F5 in the forum...

            1 Reply Last reply Reply Quote 2
            • ustkU
              ustk @orange
              last edited by ustk

              @orange Unfortunately this does not work in ma actual use case.
              Because I need to cancel the previous call if a new one has been made in between. Content.callAfterDelay will execute all previous calls with no way to cancel them.
              But since it was not in the question I asked this function perfectly does what it promises :)

              I'm then relying on a simple timer so I can stop previous call on next one, and use an external variable to copy the parameter. ;)

              Unless if it's possible to add a "cancel call" of some sort to the Content.callAfterDelay function @Christoph-Hart?

              Can't help pressing F5 in the forum...

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

              15

              Online

              1.7k

              Users

              11.8k

              Topics

              102.4k

              Posts