A strange problem occurs when the condition is false:
RET: = isboxfull (strtoint (e_boxno.text), rg_box );
If ret = true then
Begin
If application. MessageBox ('the number of tables in this box is full. Check whether the barcode is printed! ', 'System prompt', mb_yesno) = idyes then
Begin
F_main.cds_meter.close ();
F_main.sqlq_meter.params.parambyname ('boxno'). Value: = strtoint (e_boxno.text );
F_main.cds_meter.open ();
R_printinstoragenumber.print;
Rb_newbox.checked: = true;
Cds_maxboxno.close ();
Cds_maxboxno.open;
E_boxno.text: = inttostr (cds_maxboxno ['maxboxno'] + 1 );
F_main.cds_meter.close ();
F_main.sqlq_meter.params.parambyname ('boxno'). Value: = strtoint (e_boxno.text );
F_main.cds_meter.open ();
E_meterno.text: = '';
E_meterno.setfocus ();
Exit;
End
Else
Begin
If application. MessageBox ('the number of tables in this box is full. Are you sure you want to change the new box number to the database! ', 'System prompt', mb_yesno) = idyes then // you need to modify
Begin
Rb_newbox.checked: = true;
Cds_maxboxno.close;
Cds_maxboxno.open;
E_boxno.text: = inttostr (cds_maxboxno ['maxboxno'] + 1 );
F_main.cds_meter.close ();
F_main.sqlq_meter.params.parambyname ('boxno'). Value: = strtoint (e_boxno.text );
F_main.cds_meter.open ();
E_meterno.text: = '';
E_meterno.setfocus ();
End
Else
F_main.cds_meter.close ();
F_main.sqlq_meter.params.parambyname ('boxno'). Value: = strtoint (e_boxno.text );
F_main.cds_meter.open ();
E_meterno.text: = '';
E_meterno.setfocus ();
Exit;
End;
End;
Why is the exit statement still executed when ret = false?
What if I add a showmessage ('OK') Before exit? If it is added before, it will jump to exit. If it is added later, it will not jump in. This is not a hidden rule of Delphi.
Ah? Maybe so, Borland didn't announce it.