1

Can you exit from script based on IF condition

If I want to end a script is there an "exit" or Goto statement that would allow me to bypass all remaining lines?

3 replies

null
    • Fred
    • 11 mths ago
    • Reported - view

    One way would be to not have an ‘else’ part.

    But I’m suspecting your question is a bit more complicated than that. Can you expand on your situation?

    • checkyourmirrors
    • Matthew_Moran
    • 11 mths ago
    • Reported - view

    I'm looking at doing something for multiple users and IF they want certain triggers to occur. For example if user Jane as "Birthday Reminder" checked in her profile, the code when she adds a persons birthday would create a task/reminder. However if John doesn't have that checked, it should be bypassed. So basically I'd like to see "bday_remidner = no" the script should end/exit otherwise continue on. I see your point about the IF/THEN however some of my scripts are fairly long and have other IF/THEN statements and having to add a top level one to bypass the rest I see could work. I was hoping for something a bit more simple like "if bday_reminder = No then EXIT" (or GOTO END)

    • Fred
    • 11 mths ago
    • Reported - view
    Matthew said:
    I was hoping for something a bit more simple like "if bday_reminder = No then EXIT" (or GOTO END)

     Sadly Ninox does not, to the best of my limited knowledge, have anything like this. Unless someone else in this group knows more.

    I understand not wanting to add another layer of if/then.

    You could use a switch function, a bit of a overkill for a binary but it is a different look.

    switch bday_reminder do
    case 1:
    your code
    end
    

    So your code would only run if bday_reminder is set to yes (or 1). Since we don't give a solution for no (or 0) the formula doesn't do anything. Again kind of the same as if/then just looks different. I like switches as it creates a more readable format for me.

Content aside

  • Status Answered
  • 1 Likes
  • 11 mths agoLast active
  • 3Replies
  • 113Views
  • 2 Following