Exit from script

How do I terminate script execution when I certain condition is met?
if cond exit script otherwise continue script.

$[1b=condition;exit 0;continue]

http://code.kx.com/wiki/Reference/exit

HTH,

Sean

In latest kdb+ 32 bit version that kills q also.
I wanted to only stop processing the script. Or put it in other words, I am running a “program” and on certain condition I want to finish the “program”, but not the whole q system with it.

could load the script in protected eval, throw a signal if you want to exit early.

$ more a.q

a:til 10

'`earlyExit

b:til 10

$ q

KDB+ 3.3t 2015.02.17 Copyright (C) 1993-2015 Kx Systems

..

q)@[system;“l a.q”;{$[x~“earlyExit”;::;'x]}];

q)a / a was set

0 1 2 3 4 5 6 7 8 9

q)b / b was not set

'b

On Tuesday, February 24, 2015 at 12:16:41 PM UTC-5, Greg Borota wrote:

.. I am running a “program” and on certain condition I want to finish the “program”, but not the whole q system with it.

I would recommend that you turn your “program” into a function and use the return operator “:” (http://code.kx.com/wiki/JB:QforMortals2/execution\_control#Return\_and\_Signal):

q)program:{-1"do a";if[x=0;:x];-1"do b";x}

q)program 0

do a

0

q)program 1

do a

do b

1