Program execution logic:

Fun Function1 {
        AlertDateBeforeall ()
        Function3 ()
        Function4 ()
Some kind of code >

function2 (), Function3 (), Function4 () is the functions of calibration to the conditions. If there is no observance of some condition in some of the functions, an alert is displayed and the program should stop.

How to specify the operation of the code in the conditions of these functions if the condition is not satisfied (or executed)?

@requiresapi (build.version_codes.o)
Fun FirstFragment.alertDateBeforeall () {
    if (dataIsk.isBefore (dataStartSid) || dataIsk.isBefore (dataString3parse) || dataIsk.isBefore (dataString4parse) || dataString3parse.isBefore (dataStartSid) || dataString4parse.isBefore (dataStartSid) || dataString4parse.isBefore (dataString3parse)) {
        Val DialogBuilder= Alertdialog.builder (Context)
        With (DialogBuilder) {
            Seticon (r.Drawable.alert_icon)
            Settitle ("Check the dates!")
            SetMessage ("The sequence of the entered dates is broken!")
            Setcancelable (False)
            SetnegativeButton ("OK", Dialoginterface.ONClicklistener {
               DialogAlert, ID ->
            Show ()

in Kotlin FUN EXITPROCESS (STATUS: INT): NOTHING . But it does not work for me.

You can of course "turn over" condition ...

The validation of the conditions is submitted to individual functions because they are used in the code repeatedly.

Similar questions have already been considered


Well, check -if an alert came from the function, then stop.

Эникейщик2021-08-22 22:27:07

How to Quit Android Application Programmatically

zed2021-08-22 22:27:07

We must not "kill" the program, but just stop. To the user returned to enter the correct data.

jurvrn2021-08-22 22:27:07

If they reached RETURN (without labels), then there are no other options. Print something into the log right in front of Return to check, you reached it or not.

Vadik2021-08-22 22:27:07

Function2 (), Function3 (), Function4 () is the functions of calibration to the conditions -and how do they work? They must return a boolean result and then you need to write if (function2 ()) Return

DrMcSheen2021-08-22 22:27:07

Do you know the keyword RETURN? Put it in any place where you need to "stop" the function and it stops work.

zed2021-08-22 22:27:07

If you need to interrupt the entire chain of execution of functions on certain conditions and not to check the code check everywhere, you can use coat and simply cancel it when necessary. Thus, you interrupt all the execution of the code.

Pentiux2021-08-22 22:27:07