I made this to test just the section in question.
The expected message boxes when running are the following:
First loop(loop 0):
"Twin Double GF 3"
"Adding Twin"
Loop 0 Ending: cut type is: Twin template is: Double GF remaining is: 1
second loop(loop 1):
"Nocut Single GF 1"
"Adding Nocut"
"Loop 1 Ending: cut type is: Nocut template is: Single GF remaining is: 0"
"COMPLETE"
What I'm getting is:
First loop(loop 0):
"Twin Double GF 3"
"Adding Nocut"
Loop 0 Ending: cut type is: Nocut template is: Double GF remaining is: 2
second loop(loop 1):
"Cut Single GF 2"
"Adding Nocut"
"Loop 1 Ending: cut type is: Nocut template is: Single GF remaining is: 1"
"Cut Single GF 1"
"Adding Nocut"
"Loop 2 Ending: cut type is: Nocut template is: Single GF remaining is: 0"
"COMPLETE"
From what I can tell the variable v_Cut_Type is being changed to Nocut before the second set of if statements.
Code: Select all
#NoTrayIcon
Gui, add, text, x10 y19 w100 h50, Run this code
Gui, Add, Button, Default x152 y41 w70 h20 vButtonRun, RUN
Gui, Show, w228 h64, Code snippit Gui
HotKey, Enter, ButtonRun
return
ButtonRun:
HotKey, Enter, Off
Gui, Submit, NoHide
v_Cut_Next = 0
v_Loop = 0
v_Remaining_Quantity = 3
While v_Remaining_Quantity > 0
{
If (v_Cut_Next = 1 And v_Remaining_Quantity > 0)
{
;print cut single
v_Cut_Type :="Cut"
v_Template := "Single GF"
MsgBox, %v_Cut_Type% %v_Template% %v_Remaining_Quantity%
}
Else If (v_Remaining_Quantity > 1)
{
;print 2 up
v_Cut_Type :="Twin"
v_Template := "Double GF"
MsgBox, %v_Cut_Type% %v_Template% %v_Remaining_Quantity%
}
Else If (v_Remaining_Quantity > 0)
{
;print nocut single
v_Cut_Type :="NoCut"
v_Template := "Single GF"
MsgBox, %v_Cut_Type% %v_Template% %v_Remaining_Quantity%
}
If (v_Cut_Type :="NoCut")
{
v_Cut_Next := 1
v_Number_To_Print := 1
v_Remaining_Quantity := v_Remaining_Quantity - v_Number_To_Print
Msgbox, Adding Nocut
}
Else If (v_Cut_Type :="Cut")
{
v_Cut_Next := 0
v_Number_To_Print := 1
v_Remaining_Quantity := v_Remaining_Quantity - v_Number_To_Print
Msgbox, Adding Cut
}
Else If (v_Cut_Type :="Twins")
{
v_Cut_Next := 0
v_Number_To_Print := v_Remaining_Quantity // 2
v_Number_Printed := v_Number_To_Print * 2
v_Remaining_Quantity -= v_Number_Printed
Msgbox, Adding Twin
}
Else
{
Msgbox, Fail
}
MsgBox, Loop %v_Loop% Ending: cut type is: %v_Cut_Type% template is: %v_Template% remaining is: %v_Remaining_Quantity%
v_Loop += 1
}
MsgBox, COMPLETE
Return
GuiClose:
ExitApp