Anyone mind explaing Arrays
I have been trying to teach myself macros and these just surpass me.
/for i 1 to 10
This would change i to 1, next time i is used would it change it to 2? am i even using this right?
/declare MyArray[5] int
That would make 5 possible MyArrays? Or do i need to Define each?
Macro
This is what i was messing around with to check and clear the Array also
Macro
Would anyone mind helping me refine my skills with these please ;)[/syntax]
Wed Jan 16, 2013 12:44 pm
i is a variable so you want brackets on it.
Also, i think the equals operator for macros is "=="
You want to group everything that is getting looped in brackets also, that way the macro knows when to loop back up to the /for
Also, i think the equals operator for macros is "=="
You want to group everything that is getting looped in brackets also, that way the macro knows when to loop back up to the /for
Macro
Wed Jan 16, 2013 3:43 pm
Project Lead
I'm so rusty, don't put brackets on your loop, end it with /next i
Macro
Wed Jan 16, 2013 3:48 pm
Project Lead
I just noticed you were using /goto to finish the loop structure. /next is the last line that increments i and sends the flow back up to the /for.
Would output
1
2
3
4
5
Would infinitely loop and would output:
1
2
2
2
2
2
Etc
The first time through x is set to 1, so it prints a 1. Then varset sets it to 1, then next x sets it to 2 and sends it back to the top where it prints a 2, etc. it's because of this that you loop logic needs to be solid.
Macro
Would output
1
2
3
4
5
Macro
Would infinitely loop and would output:
1
2
2
2
2
2
Etc
The first time through x is set to 1, so it prints a 1. Then varset sets it to 1, then next x sets it to 2 and sends it back to the top where it prints a 2, etc. it's because of this that you loop logic needs to be solid.
Wed Jan 16, 2013 9:03 pm
Project Lead
Macro
Cold be looked at as the following, the /for is just a shortcut sort of
Macro
The top 3 lines are the /for the bottom 3 are the /next
[/quote][/syntax]
Wed Jan 16, 2013 9:11 pm
Project Lead
/for i 1 to 10
This would change i to 1, next time i is used would it change it to 2? am i even using this right?
By itself no. The /next i command is necessary to create a loop and to increment i to 2, then 3, etc. See Maudigan's examples.
/declare MyArray[5] int
That would make 5 possible MyArrays? Or do i need to Define each?
That declaration creates a single array. However, that single array can hold 5 integers. You don't need to define each but you do need to /varset each if you want them to start with a number other than zero.
Macro
In the first code section, ${MyArray[${i}]} is an integer array populated with spawn ID's. If so, your /target commands in this quoted code section won't work. If you want to target by id, then you need the id parameter:
/target id ${MyArray[${i}]}
With that said, you don't need the target command at all:
Macro
Whenever you use temporary variables like the i in this case, you want to use local scope. That means you have to declare it in the same Sub.
Wed Jan 16, 2013 11:31 pm
Senior Project Member
Macro
Thanks i think this is going to work very nice, This is a test macro i threw together to see if it will work, It adds targets and takes them away Very nice
Going to Start adding the real subs in now and seeing if causes any problems, Once again Thx for the info
Thu Jan 17, 2013 10:27 am