Page 1 of 1

Using menu gui as a counter

Posted: 29 May 2018, 19:25
by dice4321
I'm trying to use the menu GUI as a counter, I want it to count up to 6 and reset back to zero, but everytime it counts up to 6 and restarts to 0 it crashes

Code: Select all

	RetirementCounter := Mod(Sortiecount, 6) 
	ti := RetirementCounter+1
	Menu, Main, Rename, %RetirementCounter%, %ti%
	RetirementCounter += 1
	SortieCount++
Image

Is there a way to achieve getting a counter into the menu gui?

Re: Using menu gui as a counter

Posted: 29 May 2018, 20:11
by wolf_II
use Try like this:

Code: Select all

	RetirementCounter := Mod(Sortiecount, 6) 
	ti := RetirementCounter+1
	Try, Menu, Main, Rename, %RetirementCounter%, %ti%
	RetirementCounter += 1
	SortieCount++
I hope that helps.

Re: Using menu gui as a counter

Posted: 30 May 2018, 01:28
by dice4321
Thanks wolf, it stopped crashing but now its just stuck at 6, getting closer to the solution!

Re: Using menu gui as a counter

Posted: 30 May 2018, 02:57
by wolf_II
Try this:

Code: Select all

old := Count := 1
Menu, MainMenu, Add, %Count%, Label
Gui, Menu, MainMenu
Gui, Add, Button, w250 h100, Next
Gui, Show

Label:
Return

ButtonNext:
new := Mod(Count++, 6) + 1
Menu, MainMenu, Rename, %old%, %new%
old := new
Return
I hope that helps.