Expand my Community achievements bar.

Exiting from an event

Avatar

Former Community Member

Hi,

Apologies in advance for what is probably a really basic question however I can't find the answer anywhere...

is there an easy way to exit from an event without executing all the formcalc code?

Cheers,

David

5 Replies

Avatar

Level 10

Hi David,

If you have a look at the end of this example, you will see how you can check how the user has exited the field. Wrap the condition you want in an if statement.

http://assure.ly/j1KdNq

Hope that helps,

Niall

Avatar

Former Community Member

Hi,

Thanks for that, interesting! However unfortunately that wasn't quite what I was looking for, let me try to explain a bit more...

What I have is some code in an exit event and in some circumstances I do not want that to be executed so ideally what I'd like to do is at the start of the event:

if check = failed

exit   ;i.e. don't execute any of the other code below

endif

Obviously I could wrap all the code around the IF condition but I was wondering if I could do something more like the above?

Cheers,

David

Avatar

Level 10

Sorry David,

I answered thinking I was in a different thread.

I would approach it from:

if (check eq passed) then

     // your script block

endif

So that the script inside the if statement will only fire if the condition is met.

Does that make sense?

Niall

Avatar

Former Community Member

Thanks Niall - that does make sense. I was just wondering however whether there was any way I could exit up-front rather than have to nest all my script block between the IF ENDIF statements? In other languages you can do EXIT or RETURN for example to exit a method or subroutine.

Cheers,

David

Avatar

Level 10

Hi David,

"return" is reserved for use within a function. You cannot use it outside of a function.

"break" is used within a loop or switch statement.

Not sure about "exit", but I suspect not.

Niall