I've only ever built some simple macros and I'm sure my issue is caused by a noob mistake, but I can't for the life of me figure it out or find useful help online. I would appreciate it if someone could provide some insight.
What I'm trying to do
It's programming 101 stuff: I want to create a variable that acts as an index, and check its value against a constant so that a while loop will continue as long as the index is less than the constant.
How I did it
The screenshot below is taken after I pressed the Run button (equivalent to ⌃⌘R) at the top of KM's interface. You can see that
Under the Set Variable action, the current value of the variable localInboxIndex is still empty instead of 0
In the Alert window, the value of localInboxIndex is 0 (the value 25 belongs to the aforementioned constant)
In the conditions section of the while loop, I deliberately changed the condition from "index < constant" to "index exists", to demonstrate in the screenshot that as far as the while loop Action is concerned, the index variable doesn't even exist
I recreated your macro and in the while section I put in an Alert action. Running the macro displayed that alert, which indicates that the variable exists. What do you get when you try something like that?
In your example, did you perhaps mean to put the alert inside the while loop?
As @kevinb has said, you need to have your Actions inside the loop for the loop to do anything. Here is an example of a loop where the variable is incremented by I on each loop, until the variable is more than 5. (The reason for the pause Action in the example, is that otherwise the loop would run too quickly for you to see the numbers counting up.)
You could also use an "Until" Loop. A difference between the "While" loop and the "Until" loop is that the "While" loop will exit the instant the condition is met and the "Until" loop will still complete all its Actions after the condition is met and then exit the loop.
Just an FYI, if you’re basing a local variable’s existence on the real-time “evaluate conditions” feature, that’s where the problem lies. Local variables do not exist outside of the macro’s execution... which means that the real-time evaluate conditions feature of many actions (as shown in the in your screenshot) will never show local variables, since they are created only when the macro executes, and no longer exist once it’s done executing.