I know what you mean - in a regular programming language, you'd be able to do such a thing, but I'm just about 90% sure you cannot do that within a trigger. You'll have to break it up onto multiple lines, unfortunately...
I often find small annoyances like this in the editor - simple things that, by lack of a basic feature, take excessive amounts of work-arounds and time.
Yeah, unfortunately, that is not possible. If it is a really huge array and you would have to input lots of stuff, you can add the values to a string and make a loop read it: (pseudocode)
PS: An integer-type variable array of 50, is that too fat? Local or global?
What do you mean? An integer array with size 50? Totally fine. You can start worrying, if you reach 100k
Quote:
Should I avoid using variables to define constants?
Not sure what you mean? All constants are variables. And if you are talking about using literals instead of constants, in general constants should be preferred. Most compilers replace them with the literal value anyway, so it makes no difference at runtime, but its usually a lot more readable.
Quote:
Which brings me to another question: Can you make variable arrays constant? (Different values in the arrays)
Not sure what you are asking. You cannot change array size dynamically, and I don't think you can make a constant array.
It would definitely be possible to do it with a single action call, as SouLCarveRR is describing.
The way to do it would be using arrayref to pass the array as a parameter. The limitation of this is that you will only be able to use the action for a specific type of array (like an action that initializes an int array of size 5). But you could always just code multiple such actions.
You know, like
lv_code[5] = {5, 4, 3, 2, 1};
I know I can do it per variable array but in this case, I want it like that.
PS: An integer-type variable array of 50, is that too fat? Local or global? Should I avoid using variables to define constants?
Which brings me to another question: Can you make variable arrays constant? (Different values in the arrays)
Member since 2010. Made the -The Thing- [Revival] game. Nostalgic of the WC3 days.
I know what you mean - in a regular programming language, you'd be able to do such a thing, but I'm just about 90% sure you cannot do that within a trigger. You'll have to break it up onto multiple lines, unfortunately...
I often find small annoyances like this in the editor - simple things that, by lack of a basic feature, take excessive amounts of work-arounds and time.
Yeah, unfortunately, that is not possible. If it is a really huge array and you would have to input lots of stuff, you can add the values to a string and make a loop read it: (pseudocode)
Still sucks, but at least you can add new values really fast.
What do you mean? An integer array with size 50? Totally fine. You can start worrying, if you reach 100k
Not sure what you mean? All constants are variables. And if you are talking about using literals instead of constants, in general constants should be preferred. Most compilers replace them with the literal value anyway, so it makes no difference at runtime, but its usually a lot more readable.
Not sure what you are asking. You cannot change array size dynamically, and I don't think you can make a constant array.
you can take that string idea a bit farther and use an action definition to automate it a bit more.
It would definitely be possible to do it with a single action call, as SouLCarveRR is describing.
The way to do it would be using arrayref to pass the array as a parameter. The limitation of this is that you will only be able to use the action for a specific type of array (like an action that initializes an int array of size 5). But you could always just code multiple such actions.
Here's an example: