Home › Forums › General › Programming › Issue with panel initialization
Tagged: panel load initialize init
- This topic has 7 replies, 2 voices, and was last updated 8 years, 5 months ago by goodweather.
-
AuthorPosts
-
November 1, 2015 at 9:36 am #61763
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.94November 7, 2015 at 6:04 pm #62360No idea from anyone?
November 7, 2015 at 10:25 pm #62376i 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 identifieryou 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
November 8, 2015 at 10:50 am #62398Hi, 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?
November 8, 2015 at 6:40 pm #62430i 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 inif 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
November 9, 2015 at 9:54 am #62474Thx 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…November 9, 2015 at 10:57 am #62475don’t take care about vstIndex
go to panel property -> utility
in the order you see all your mods in xmlchose 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’November 9, 2015 at 6:40 pm #62509Hi, 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? -
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.