Home Forums Macros How can I retrigger Matrix Macro so new Case Branch triggers? Reply To: How can I retrigger Matrix Macro so new Case Branch triggers?

#6307
Philippe OllivierPhilippe
Keymaster

Hi,
The issue here comes from the fact we cannot stop the RepeatWhile loop from outside.

I think you can set the buttons in toggle mode and add a condition to stop the RepeatWhile loop if the button is set to off or another button is pushed.
I don’t know if this will work in your situation, but it could be a solution.
Below is a simple example of this.
Best,
Philippe

//******************************** Matrix ! Tab Items ********************************
Declare Local Once boolean $firstTime$ = true
Declare Local Once int $itemSize$ = 56
Declare Local Once int $lastPushedItem$ = -1

If { $firstTime$ }
$firstTime$ = false
SendData thispatcher itemamount 8
WaitDuration 200
SendData mainWindow setsize 463 {30 + ($itemSize$ * 1)}

// Toggle mode On
SendData item 0 mode 1

SendData thispatcher basicdisposition
SendData MacroInitialized
MacroStop
EndIf

CaseBranch 1
SendData item $lastPushedItem$ set 0
$lastPushedItem$ = {currentCaseValueInt()}

RepeatWhile {(currentCaseValueInt()==1) && (currentCaseOptionValueInt(0) == 1)}
Post {“Loop ” + (currentCaseValueInt())}
WaitDuration 30
EndRepeat
BreakCaseBranch

CaseBranch 2
SendData item $lastPushedItem$ set 0
$lastPushedItem$ = {currentCaseValueInt()}

RepeatWhile {(currentCaseValueInt()==2) && (currentCaseOptionValueInt(0) == 1)}
Post {“Loop ” + (currentCaseValueInt())}
WaitDuration 30
EndRepeat
BreakCaseBranch

CaseBranch 3
SendData item $lastPushedItem$ set 0
$lastPushedItem$ = {currentCaseValueInt()}

RepeatWhile {(currentCaseValueInt()==3) && (currentCaseOptionValueInt(0) == 1)}
Post {“Loop ” + (currentCaseValueInt())}
WaitDuration 30
EndRepeat
BreakCaseBranch

CaseBranch 4
SendData item $lastPushedItem$ set 0
$lastPushedItem$ = {currentCaseValueInt()}

RepeatWhile {(currentCaseValueInt()==4) && (currentCaseOptionValueInt(0) == 1)}
Post {“Loop ” + (currentCaseValueInt())}
WaitDuration 30
EndRepeat
BreakCaseBranch