# Difference between Integer A, Integer B, custom integer?

Status
Not open for further replies.

#### chasin225

Level 7
what is the differance of these 3 actions?:

• For each (Integer A) from 1 to 10, do (Actions)
• Loop - Actions
• For each (Integer B) from 1 to 10, do (Actions)
• Loop - Actions
• For each (Integer QB_Level) from 1 to 10, do (Actions)
• Loop - Actions

edit: i get it now thanks for he explenation.

Last edited:

#### kleinerhauck

Level 13
Each uses a different loop variable......
You can always use Integer A unless you need a loop within another loop or (and that's a reason for bugs!!) another trigger with a IntegerA-Loop is executed while an IntegerA-Loop is already running.

#### Maker

Level 37
Custom variable is better since it's faster.

• For each (Integer A) from 1 to 10, do (Actions)
• Loop - Actions
->
JASS:
``````set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop``````

• For each (Integer i) from 1 to 10, do (Actions)
• Loop - Actions
->
JASS:
``````set udg_i = 1
loop
exitwhen udg_i > 10
set udg_i = udg_i + 1
endloop``````
One less variable setting.

And when you call the variable inside the loop:
• Set ID = (Integer A)
->
JASS:
``set udg_ID = GetForLoopIndexA()``
So that calls a function that returns the value set to bj_forLoopAIndex.

• Set ID = i
->
JASS:
``set udg_ID = udg_i``
No function call.

#### -Kobas-

Level 39
Integer A and B are blizzard global variables used in for functions!
It was faster for programmers to just pick 1 (usually A) variable already used with function and do what they need to do...
Still there was situations when they needed 2 functions so they added Integer B for just in case!
For function with custom variable is default one, basic thing

Status
Not open for further replies.

Replies
3
Views
2K
Replies
28
Views
3K
Replies
4
Views
623
Replies
5
Views
771
Replies
9
Views
648