Using global variables within Snap! custom blocks can be useful at times but can lead to issues.
This is prompted by me wanting to create a fast decimal ->hex convertor that uses a large lookup table and I want to hold the lookup table as a global var so it only gets created once to speed things up
Note: I've a pretty good idea that Jens would prefer us not to do this at all but lets not get into that here
So, the main published library to do this is the Colors and Crayons one.
It avoids any possible name space clashes by prefixing the variables with a pen icon
I'm suggesting that we come up with some sort of agreed protocol (between us Snap! users) to do something similar if we publish custom blocks/libraries for others to use
So my suggestion is to prefix any such global vars with our usernames (as they should be unique)
Does anyone have an alternative suggestion to achieve the same result
That makes for some very long variable names. Potentially we could do, like, two to four letters of our username instead. In some projects and stuff, I identify with "PJ21" rather than "pajamaclaws21" simply because of length.
And the var would only be being used within your own custom block so if it's long - does it matter?
But, in practice, not many people are going to be using this technique (as it's a last resort) so using a shortened prefix would 99.99% work in practice
Hmm... How about a script pic tracks the username that put the script pic, so when the variable is dragged from the script pic to a project, it puts the username in the variable name?