I have the following code in a number of command buttons:
// Make sure you're not in the Retrieve Spec
IF @MODE() = 2
THEN @MSGBOX("This button does not work in Search Mode","","")
ELSE
// Tests to be sure an Invoice Number has been assigned
IF @IsBlank(INVOICE_NO_1)
THEN
{
NotifyForm(1)
@MsgBox("The Invoice Number has not been assigned.","Please click ASSIGN INVOICE #","")
}
ELSE
// Tests to be sure the Invoice has been Coded
IF @IsBlank(CODING)
THEN
{
NotifyForm(1)
@MsgBox("This Invoice has not been assigned a job type Code.","","")
Throwfocus(CODING)
}
ELSE
// Tests to be sure a Salesman has been assigned
IF @IsBlank(SALESMAN)
THEN
{
NotifyForm(1)
@MsgBox("Please assign a Salesman to this Invoice.","","")
Throwfocus(SALESMAN)
}
ELSE
// Check to make sure you don't have a positive Credit Memo
IF (PURCHASE_ORDER_NO = "CREDIT MEMO" and INVOICE_TOTAL > 0)
THEN @MsgBox("The total for this credit memo is a positive amount.", "Make it negative or change the P.O. description", "")
ELSE
// Saves the record and then Exits
{
Clear(Checkcode)
NotifyForm(0)
FormCommit("")
@Exit
}
They're all the same except for the first Mode check and the final Save/Save&Continue/Save&Exit process. I would like to move the middle four tests into a subroutine, PerformSaveTests(), but I'm not sure how the "ELSE" situations would work. This doesn't work:
// Make sure you're not in the Retrieve Spec
IF @MODE() = 2
THEN @MSGBOX("This button does not work in Search Mode","","")
ELSE
PerformSaveTests()
ELSE
// Saves the record and then Exits
{
Clear(Checkcode)
NotifyForm(0)
FormCommit("")
@Exit
}
The program editor balks at that last ELSE, but if it's not there then the final action will be performed every time. What am I missing here? Thanks for any help.