Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Goto or jump functions

    Coding
    5
    22
    934
    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.
    • pianofire
      pianofire Fuze Team @Mechanical last edited by pianofire

      @Mechanical So variables can be local or global. As you say variables that are declared within a function are local to it and will cease to exist outside of the function. Variables declared outside of a function are global and they will persist even after the function has exited.

      P 1 Reply Last reply Reply Quote 0
      • P
        petermeisenstein F @pianofire last edited by

        @pianofire but with the next update there will changes right?

        pianofire 1 Reply Last reply Reply Quote 0
        • pianofire
          pianofire Fuze Team @petermeisenstein last edited by

          @petermeisenstein There will be a change to the way that parameters are passed to functions. Global and local variables will remain the same.

          M 1 Reply Last reply Reply Quote 0
          • M
            Mechanical @pianofire last edited by

            @pianofire sooo, practically I need to change Syntax when the new update rolls out? Or does it stay the same on the frontend?

            pianofire 1 Reply Last reply Reply Quote 0
            • pianofire
              pianofire Fuze Team @Mechanical last edited by

              @Mechanical There was some confusion about whether parameters were being passed to functions by reference or by value. To clarify the situation the default is now by value and if you want to pass by reference you will need to add "ref" in front of the parameter (from the next patch)

              P 1 Reply Last reply Reply Quote 0
              • P
                petermeisenstein F @pianofire last edited by

                @pianofire but it wont be possible for variables declared "new" in your function so a variable who is only declared inside your function

                pianofire 1 Reply Last reply Reply Quote 0
                • pianofire
                  pianofire Fuze Team @petermeisenstein last edited by

                  @petermeisenstein Sorry I don't understand the question

                  P 1 Reply Last reply Reply Quote 0
                  • P
                    petermeisenstein F @pianofire last edited by

                    @pianofire So here is an example

                    function()
                    my_variable=1
                    return void

                    Can i use my_variable outside this function

                    pianofire 1 Reply Last reply Reply Quote 0
                    • pianofire
                      pianofire Fuze Team @petermeisenstein last edited by pianofire

                      @petermeisenstein So if you declare the variable outside of the function it becomes global and can be used anywhere:

                      int my_variable = 0
                      
                      function test()
                        my_variable=1
                      return void
                      
                      test()
                      
                      print(my_variable) // value will now be 1
                      
                      P 1 Reply Last reply Reply Quote 0
                      • P
                        petermeisenstein F @pianofire last edited by

                        @pianofire Ok thanks

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