I would like to ask someone to share some guidelines for differentiating dynamic variable definitions and pseudo-arrays.
After many hours of debugging my script I've removed most of the code just to find out a strange situation: depending on variable operation the script either fails or succeeds to perform a task. Here's the code:
Code: Select all
#SingleInstance Force
Global imgGuiId
If imgGuiId == ""
imgGuiId := 0
;; --------------------------- CASE: "++" VS "+1"
;; imgGuiId := imgGuiId + 1
imgGuiId++
;; ---------------------------
Gui guiName%imgGuiId%:New, +HWNDhGuiName%imgGuiId% ;; hGuiName1
Gui guiName%imgGuiId%:Add, Button, +Default +W50 +H20 +GguiName_Enter, ok
GuiControl Hide, ok
Gui guiName%imgGuiId%:Show, w200 h150
Return
guiName_Enter:
Global imgGuiId
WinGet actWndId, ID, A
Loop % imgGuiId
;; ---------------------------
;; WHEN "imgGuiId := imgGuiId + 1" is used: FAILS to read "hGuiName%A_Index%" as "hGuiName1" and returns
;; WHEN "imgGuiId++" is used: SUCCEEDS to read "hGuiName%A_Index%" as "hGuiName1" and closes the gui
If (actWndId == hGuiName%A_Index%)
Gui guiName%A_Index%:Destroy
;; ---------------------------
Return
Esc::ExitApp
My question is specifically related only to this situation of swapping those code lines - the rest of the code (with dynamic variables) performs as expected (within the rest of the script).
Please, share some thoughts