Issue with panel initialization

Home Forums General Programming Issue with panel initialization

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #61763
    goodweather
    Participant
      • Topics: 45
      • Replies: 550
      • Total: 595
      • ★★★

      Hi, help would be much appreciated on the following issue…

      I understood that variables used in the different Lua methods are global. Fine.
      I have 3 objects that should be used in almost all methods and wanted to initialize them at panel load.
      I created thus a method initSub37Panel and entered the following code:

      --
      -- Called when the panel has finished loading
      --
      initSub37Panel = function()
      
      	txtParameter=panel:getModulatorByName("txtParameter")
      	txtCurrentValue=panel:getModulatorByName("txtCurrentValue")
      	txtInformation=panel:getModulatorByName("txtInformation")
      end

      In my panel, I put initSub37Panel at the “Called when the panel has finished loading” property.

      The problem is that it seems that those 3 variables are not set and all my methods using the 3 variables are locked.
      When I add the 3 lines of code above in one of my modulator’s change method and use it first then all the other methods are working fine.
      This means that the code above is correct and that the variables are indeed global.

      So… I don’t know what to do to have those variables set at panel load.
      Any idea? I have Ctrlr 5.3.94

      #62360
      goodweather
      Participant
        • Topics: 45
        • Replies: 550
        • Total: 595
        • ★★★

        No idea from anyone?

        #62376
        zeoka
        Participant
          • Topics: 73
          • Replies: 466
          • Total: 539
          • ★★★

          i think this is your methods that call identifiers are read before the panelLoaded callback is loaded so normally you have lua messages at startup : txtParameter is nil value etc…
          this is a bad place to create modulator object as identifier

          you can use a free script and call it in your methods or create local variables in them…. or put your identifiers in the first modulator that need one : see in the xml the first modulator that need identifier

          the panel global variable callback could be a place for ..but it’s better to have something to do with global variables so i don’t know

          #62398
          goodweather
          Participant
            • Topics: 45
            • Replies: 550
            • Total: 595
            • ★★★

            Hi, thx for your answer.
            This was also my diagnostic… The method identified at “Called when panel has loaded” property being called before the actual load is finished…
            I was expecting Atom to provide some support to this (probably classical) issue.

            As I don’t know in advance what modulator will be first used by the user, at this stage I added my variable assignments in all methods… Not very good programming and I don’t like that but it is working.

            So, any tip to improve this is still welcome!

            Btw, where would I put a free script? How is its content recognized by other methods? Or is it simply enough the fact that it exists in the list of methods?

            #62430
            zeoka
            Participant
              • Topics: 73
              • Replies: 466
              • Total: 539
              • ★★★

              i would mean your valueChange methods are read simply because modulators are loaded before the panel loaded method . this is normal .so in the xml text (panel properties ) :
              i assume this the loading order .the first modulator with valueChange that use one idenfier should be the good to put all identifiers in

              if you prefer
              to create a method you have to go in the lua editor , chose “none” to method type
              to call it in your valueChange methods : ex myMethodName()

              but i think it’s better to put your Id’s in the first mod loaded

              #62474
              goodweather
              Participant
                • Topics: 45
                • Replies: 550
                • Total: 595
                • ★★★

                Thx zeoka!
                How do I find which modulator is the first one loaded? Is it the first one I created (the one with the lowest VST index)?
                I could combine both ways: create a separate easy to maintain method to initiaze different things then call that method only once from the valueChange method of the first loaded modulator…

                #62475
                zeoka
                Participant
                  • Topics: 73
                  • Replies: 466
                  • Total: 539
                  • ★★★

                  don’t take care about vstIndex

                  go to panel property -> utility
                  in the order you see all your mods in xml

                  chose the first mod in the list that use an identifier and put in his valueChange method (in lua) all your identifier definitions in it .
                  that way when the panel will load your other methods will ‘know’

                  #62509
                  goodweather
                  Participant
                    • Topics: 45
                    • Replies: 550
                    • Total: 595
                    • ★★★

                    Hi, I tested it and it works fine. Thx again for your tip!
                    I used the Panel modulator list to find the first modulator and add a call to my InitSub37Panel function stored somewhere else. I put in comment all assignments in the different modulators and it works thus good with central management from one function.

                    To understand further the behaviour (I like to understand things), it means thus that the code in assignValues is somewhat tested/”executed” before the user uses it and this occurs before even the panel loaded.
                    Right? Don’t you find this a bit “strange” or is this some Lua behaviour?

                  Viewing 8 posts - 1 through 8 (of 8 total)
                  • The forum ‘Programming’ is closed to new topics and replies.
                  There is currently 0 users and 166 guests online
                  No users are currently active
                  Forum Statistics
                  Threads: 2,495, Posts: 17,374, Members: 77,605
                  Most users ever online was 12 on January 22, 2019 3:47 pm
                  Ctrlr