HISE Logo Forum
    • Categories
    • Register
    • Login

    Inline functions and const

    Scheduled Pinned Locked Moved Scripting
    4 Posts 2 Posters 234 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.
    • VirtualVirginV
      VirtualVirgin
      last edited by VirtualVirgin

      Since you can't make a const variable declaration in an inline function, is there some other way to make a variable that will be available to outside the inline function code block?

      I am making some factory methods and would like to be able include array creation along side the creation of the components.

      You can listen to my orchestral mockups here:
      https://www.virtualvirgin.net/

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

        @VirtualVirgin In the inline function put your values into a local variable and return it. Then when you call the inline function you can capture the returned value in a const.

        inline function doSomething()
        {
            local myVar = 123;
            return myVar;
        }
        
        const data = doSomething();
        
        

        I'll be posting a video about this tomorrow :)

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

        VirtualVirginV 1 Reply Last reply Reply Quote 2
        • VirtualVirginV
          VirtualVirgin @d.healey
          last edited by VirtualVirgin

          @d-healey said in Inline functions and const:

          inline function doSomething()
          {
          local myVar = 123;
          return myVar;
          }

          const data = doSomething();

          I can't figure how how to get any returns out of it if there are parameters going into it.

          inline function createMatrixTable(name, rows, columns, unitSize)
          

          Screenshot 2024-12-24 at 10.40.03 PM.png

          Screenshot 2024-12-24 at 10.38.45 PM.png

          You can listen to my orchestral mockups here:
          https://www.virtualvirgin.net/

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

            @VirtualVirgin As the error message says, testReturn is not a function, you don't need to put () at the end.

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

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

            17

            Online

            1.8k

            Users

            12.0k

            Topics

            104.1k

            Posts