Macro _hGadget
MacroExpandedCount
EndMacro
;Example 1
Debug "Example1"
Global z1 = _hGadget
Global z2 = _hGadget
Global z3 = _hGadget
Global z4 = _hGadget
Debug z1
Debug z2
Debug z3
Debug z4
;Example 2
Debug "Example2"
Global Dim az.l(4), i
For i = 0 To 3
az(i) = _hGadget ;<- HERE ERROR AFTER THE FIRST LOOP
Next
For i = 0 To 3
Debug az(i)
Next
Result :
Example1
1
2
3
4
Example2
5
5
5
5
In case of Array (Example 2) the macro seems not running after the first loop?
Is it a bug or i am doing something wrong?
Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy.
PureBasic 6.10 LTS (Linux - x64)
Macro _hGadget
MacroExpandedCount
EndMacro
For ii = 0 To 5
Debug _hGadget
Next : Debug ""
For ii = 0 To 5
Debug _hGadget
Next
Last edited by Thunder93 on Fri Mar 17, 2017 6:18 pm, edited 2 times in total.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
You're doing something wrong - you can't use MacroExpandedCount in the way you are in your second example, or at least you can't use it to get the result you were expecting anyway.
The MacroExpandedCount is handled by the macro preprocessor when the code is compiled, not at runtime. The result is correct because the macro is only expanded once in that loop in the compilation process. The loop executes more than once at runtime but this is irrelevant.