HISE Logo Forum
    • Categories
    • Register
    • Login

    call function inside function

    Scheduled Pinned Locked Moved Scripting
    14 Posts 3 Posters 548 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.
    • ulrikU
      ulrik @d.healey
      last edited by

      @d-healey I want the inner function to execute only inside the other function to avoid using globals.
      The inner function use variables that only exists inside the outer function

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

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

        @ulrik This is what namespaces are for.

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

        ulrikU 1 Reply Last reply Reply Quote 0
        • ulrikU
          ulrik @d.healey
          last edited by

          @d-healey So how do I set it up, do you have a short example where both functions use the same "private" variables?

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

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

            There are no private variables in javascript or HISE script. But in HISE script we can create variables that have scope limited to a namespace.

            namespace MyNamespace
            {
                reg myVariable = 50;
            
                inline function aFunction()
                {
                    Console.print(myVariable); // Will print 50 to the console
                }
            }
            
            Console.print(MyNamespace.myVariable); // Will print 50 to the console
            Console.print(myVariable);  // Will trigger undefined parameter error�
            

            Note that the variables must be of type reg or const to limit the scope. var will always be global.

            More info here:
            https://forum.hise.audio/topic/92/namespaces-in-javascript
            https://github.com/davidhealey/hise_documentation/blob/master/scripting/scripting-in-hise/hise-script-coding-standards.md

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

            ulrikU 1 Reply Last reply Reply Quote 2
            • ulrikU
              ulrik @d.healey
              last edited by

              @d-healey Thank you David, I will study :)

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

              1 Reply Last reply Reply Quote 1
              • Christoph HartC
                Christoph Hart
                last edited by

                @d-healey if you create a pull request for the coding standard, I'll merge it into the main doc branch so it becomes part of the HISE doc website.

                d.healeyD 1 Reply Last reply Reply Quote 1
                • d.healeyD
                  d.healey @Christoph Hart
                  last edited by

                  @Christoph-Hart Done, thanks!

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

                  1 Reply Last reply Reply Quote 0
                  • Christoph HartC
                    Christoph Hart
                    last edited by

                    Ah damn, I noticed you were using a Markdown feature that the HISE Markdown parser is not supporting (inline code examples in a bullet list):

                    -   This list item has a code example:
                    
                        ```javascript
                        CodeExample
                        ```
                    
                    -   Next Item
                    

                    This makes it look like this in the HISE doc browser:

                    256189cb-6584-44fc-b53e-9b358e2d2009-image.png

                    With a bit of whitespace correction it looks like this:

                    c8bb3538-f291-4072-b713-3167826b6793-image.png

                    However then it might not look as good in the Github preview. Hard choice :)

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

                      @Christoph-Hart I think it's more important that it looks good in the HISE docs since that's where I expect most users will find it. Do you want me to clean it up?

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

                      1 Reply Last reply Reply Quote 0
                      • Christoph HartC
                        Christoph Hart
                        last edited by

                        Nope, I'll do it, I have to add the metadata and stuff anyways. It's a pretty quick thing...

                        1 Reply Last reply Reply Quote 1
                        • Christoph HartC
                          Christoph Hart
                          last edited by

                          Alright here we go:

                          Link Preview Image
                          HISE | Scripting | HiseScript Coding Standards

                          A collection of best practices for clean coding in HISE

                          favicon

                          (docs.hise.audio)

                          I noticed that in some examples it uses 2 spaces instead of a tab (=4 spaces) now. Should be an easy fix though :)

                          d.healeyD 1 Reply Last reply Reply Quote 3
                          • d.healeyD
                            d.healey @Christoph Hart
                            last edited by

                            @Christoph-Hart Thank you!

                            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

                            39

                            Online

                            1.8k

                            Users

                            12.1k

                            Topics

                            105.1k

                            Posts