In the onLoad event of a form if we present this process:
if(sc_btn_new)
{
process 1;
}else{
process 2;
}
When the user has entered their data, pressing the insert button, and in the onValidate or onValidateFailure event occurs:
…sc_message_error(‘Error’); sc_error_exit();
The form returns to the onLoad event, but sc_btn_new is no longer true, since it may have changed its value from true to false by pressing the insert button. In this case, process 2 is executed, which should not be the case, since we are still in the process of inserting a new record, the only thing that has happened is that we do not allow it to be inserted as it is because some data is wrong.
The user is only being informed to correct his input data and try to add the record again, so the form should remain in the state left by process 1, not execute process 2, which will possibly leave the form in other state, for example read-only or not visible fields, disappearing blocks, etc., for an update process, not for a new record.
If the true value of sc_btn_new cannot be preserved, for whatever reason, within the Scriptcase system when the insert button is pressed, Scriptcase could create a new macro called for example sc_validate_error and be able to act like this:
if(sc_btn_new)
{
process 1;
}else{
if(!sc_validate_error)
{
process 2;
}
}
Greetings