Navigation

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

    Im confused on While

    Help
    2
    6
    310
    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.
    • Retrocade_media
      Retrocade_media F last edited by Retrocade_media

      If I have some code that says:

      Loop
      
      While layout == "game" loop
      //stuff
      Repeat
      
      Repeat
      

      It says that the variable Layout doesn't exist, and points me to the second function in the while loop. However if I do:

      Loop
      
      If layout == "game" then
      //stuff
      Repeat
      
      Repeat
      

      It works fine, no errors. I should note, none of the functions in those while/if statements reference the layout variable, nor do they reference anything that references the layout variable.
      No clue why I get this error

      1 Reply Last reply Reply Quote 0
      • PB____
        PB____ last edited by PB____

        This works fine for me:

        layout = "game"
        loop
            while layout == "game" loop
                print("stuff")
                update()
            repeat
        repeat
        

        but if you remove the first line, and this is your whole program, then it does not work:

        loop
            while layout == "game" loop
                print("stuff")
                update()
            repeat
        repeat
        

        However if you've never assigned a value to "layout" or declared it, then it won't work with an if statement either.
        So this will give the same error:

        loop
            if layout == "game" then
                print("stuff")
                update()
            endif
        repeat
        

        So without more context on where you assign a value to layout or where you declare it, to me it doesn't seem to be related to while?

        Retrocade_media 1 Reply Last reply Reply Quote 1
        • Retrocade_media
          Retrocade_media F @PB____ last edited by

          @PB____ sorry, I should clarify that I declare layout before the game loop with my other variables

          1 Reply Last reply Reply Quote 1
          • PB____
            PB____ last edited by

            If I declare the variable without assigning it, I do get an error, both when using if and when using while, so it doesn't appear to discriminate there.

            And if I do assign it a value before hand, I don't get the error.

            It is a known issue though that if an error occurs, Fuze might point to the wrong line in your code. Maybe something like that is going on? Are you sure the issue is really with the difference between loop and while?

            Retrocade_media 1 Reply Last reply Reply Quote 1
            • Retrocade_media
              Retrocade_media F @PB____ last edited by

              @PB____ yes. The only thing that changed was instead of using while I used if then. In both scenarios Layout = "Game" before the loop

              1 Reply Last reply Reply Quote 1
              • PB____
                PB____ last edited by PB____

                Weird. I must be doing something differently, because for me it works normally for both if layout == "game" then and while layout == "game" loop

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