disabling a method?

Home Forums General Programming disabling a method?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #72383
    human fly
    Participant
      • Topics: 124
      • Replies: 1070
      • Total: 1194
      • ★★★★

      i tend to work with a few scrap methods still in my Lua Editor,
      as sketchpad notes to refer to, check against, etc. – or stuff
      i’m ‘borrowing’ to try out, or work from.

      – this means i usually have doubles/’versions’/backups etc.,
      that i clear out/tidy up periodically when i don’t need them
      anymore.(easier than skipping around between files)

      and so of course, now i realise that these are also loading
      at Panel Load, and could cause issues even if unused (true?).

      my notion here is that i can disable these, simply by having
      the function name NOT correspond to the method name. is this
      correct?

      ie: if the method is called myFunction, and the function is
      called myPhunKtion(), it just won’t run, won’t load.
      is this correct? viable? (i think so, just checking)

      edit: no, this is another newb’ misconception of mine:
      functions can, of course, be loaded with a method that
      loads a library of functions, that you call by name in
      any other function. so it doesn’t matter what a function
      is called, as long as you use that name to call it later.

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

        human fly, you are again seeing things much too complicated…
        – Ctrlr methods contains functions
        – one Ctrlr method can contain several functions returning or not data
        – when a method is linked to a modulator “OnValueChange” it will be executed when you load the panel during the initialization of the panel
        – therefore, all “OnValueChange” methods should have the piece of code preventing them to run at that moment (unless you want the opposite of course)

        
        -- No action if the panel is in bootstrap or program states
        if not isPanelReady() then
        	return
        end

        isPanelReady() is a function that I have in a method that I call Miscellaneous and that contains several usefull functions. bPanelLoaded is a variable that I set to true at the end of panel load (doen by a timer displaying first a welcome message).

        --
        -- Check if the panel is not busy to load or receiving a program
        --
        isPanelReady = function()
        
        	if panel:getBootstrapState() == false and panel:getProgramState() == false and bPanelLoaded == true then
        		return (true)
        	else
        		return (false)
        	end
        
        end
        #72444
        human fly
        Participant
          • Topics: 124
          • Replies: 1070
          • Total: 1194
          • ★★★★

          hi Goodweather,
          thanks for clarifying your isPanelReady.
          i figured out enough of the rest in the meantime 🙂
          (and also for pointing out it is the OnValueChange
          methods that need that bit of code. i do use that now as a
          matter of course, to prevent things running when the panel
          loads)

          my initial post wasn’t very good. as said, i was keeping lots
          of junk methods at the time, and wasn’t sure if it could cause
          problems.i understand that well enough now.

          could you define ‘bootstrap’? ‘restoreState’? programState?

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

            ‘bootstrap’? programState: don’t remember them precisely but they are somewhat explained in the forum. The only one speaking a bit more is “bootstrap” that I simply translated by “during boot”.
            SaveState and RestoreState: I’m using those and have methods related to them.
            I must have already written something about them in the forum or in the step by step guide 2.0.
            Basicaly:
            – when you quit Ctrlr (not when you close a panel) it saves all the values of the modulators in the open panels. this is saved in the ctrlr.settings file in Appdata (PC)
            – you can add to that a save of some variables. To achieve this you use a SaveState method
            – when you open Ctrlr, it shows all open panels and their modulators
            – in the same way, at that time you can also force reloading some saved variables and you do that with a RestoreState method

            Look on the forum, there are some topics on this.

            Forgot to say: you can thus keep a test method without any problem. Just secure that it is not used by any modulator and that it has the magic piece of code preventing it to run during panel opening.

            #72446
            human fly
            Participant
              • Topics: 124
              • Replies: 1070
              • Total: 1194
              • ★★★★

              save/restoreState: excellent, thanks. that makes sense.
              i wasn’t aware of saveState.

              yes, i had noticed how previous settings come back on restart
              -uh, well sometimes, depending on what else is loading, and other
              factors (i forget what exactly right now, but i observe changes
              from file to file as i work)

              of course, VSTIndex numbers can screw up your panel load if
              2 panels share same Index numbers. pretty obvious and not a
              big deal – interesting though that Ctrlr should do this, and
              not treat panels entirely separately ie: sending out sysex:
              if 2 panels share that VSTIndex number, both messages will be
              triggered. maybe something for Roman (Roamin’, nearly had
              a typo there) to think about one day.

              #72451
              human fly
              Participant
                • Topics: 124
                • Replies: 1070
                • Total: 1194
                • ★★★★

                regarding the code snippet that stops onValueChange methods
                from running when the panel loads: do you know why my Random
                and Reset buttons do not work on the first run, when it’s
                drafted as a restricted instance exe?

                seems to happen every/most times: my Windows exe checker scans
                it, then it opens, and these buttons won’t work.
                so i then close it, and re-open, and it is normal.
                a friend i send these to has reported the same behaviour.

              Viewing 6 posts - 1 through 6 (of 6 total)
              • The forum ‘Programming’ is closed to new topics and replies.
              There is currently 0 users and 34 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