A Tutorial on Callbacks, Factories and Animation — and an Animated Disclosure Widget
-
@d-healey said in A Tutorial on Callbacks, Animation and Creating Panel Buttons — And an Animated Disclosure Widget:
@Dr-Bill
Would this be a "var" declaration, then?
Avoid var like your life depends on it. The only place they should be used is in non-inline functions.
Please do call me out when I should be using a reg variable.
All the HISE documentation links on variable types lead to 404 pages.
Not this one :)
https://docs.hise.audio/scripting/scripting-in-hise/hise-script-coding-standards.html#variables
I appreciate the link; I guess I'm particular on these things. The text you refer to is an optional style guideline; it's not documentation, nor meant to be. Any technical discussion therein is incidental, incomplete, and not within a referential context.
This is the documentation link for data types is here: ```
https://docs.hise.audio/scripting/scripting-in-hise/javascript.html#data-types -
@ustk Thank you for taking the time to write this code. I've incorporated your colour assignment, as that's simpler than referring the user to the Properties panel—nice thinking. Please understand that I am writing a tutorial; you code is certainly more efficient, but not pedagogical. (I love your use of the data extension.)
Can you please explain what you mean by "…don’t use var but reg for what can be modified"?
-
@Dr-Bill
Can you please explain what you mean by "…don’t use var but reg for what can be modified"?
Always use
reg
for any data that isn't constant (except arrays/objects). The only time you should usevar
is in functions, and that's only because we have no other choice. The reason to avoid var is becausevar
leaks into the script wide namespace. -
-
@Dr-Bill
I originally had the variables outside the functions as reg
Sounds like you had it right for those variables. If they needed to be script-wide then reg was the way to go.
-
@d-healey What's funny is that in my comments explaining why I used reg variables, I named-check you, saying you preferred reg variables. (Look back through the post edits back to the initial post.)
Bottom line is you guys are both are far more knowledge about HISE than me. I appreciate your insights on my tutorials, and help with my forum questions—thank you.
-
@Dr-Bill no worries, my pleasure to contribute
I don’t take what you said badly of course, but I think a method that is more straight forward and doesn’t lead beginners to bad practices can’t be less pedagogical than your method.
I don’t have the time to comment my code today though, excuse me for this… -
@ustk I'll have a think on that for the next tutorial I write - cheers, mate.
-
@Dr-Bill Excuse me if, as a non native speaker, what I wrote offended you in some ways, it was absolutely not meant to do it...
That been said, your demonstration still contains some hiccups if I might say it this way.
I have to go more deeply through your code because tonight I run out of time, but there's one thing that I think is weird.
You are talking about globals, I understand what you mean regarding the tuto, they global in a sense. But global variables are defined usingglobal
and have a special purpose, which is being accessed from other scripts. -
@ustk Not at all, mate. You and what you wrote are awesome; I appreciate the opportunity to learn from someone as knowledgable about HISE as you. I value any critiques you can offer from going through my code - thank you! I'll follow up on any suggestions/corrections you make.