Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
If a certain condition is not true, I would like to intentionally fail the script execution. (I need to send an email regarding this condition from the server and not through a front - end alert..) I am having trouble devising an algorithm which fails only under this condition. Any syntax errors will fail always.
Ideally there would be something in my script like: if( MyConditionIsFalse, SCRIPT FAILS HERE, Script does not fail here)
Thoughts? Thanks!
Scott
Hi,
Something like this maybe?
Table:
LOAD * INLINE [
F1, F2
A1, B1
A2, B2
A3, B3
];
LET vScriptStatus = NoOfRows('Table');
// Your condition here
IF $(vScriptStatus) > 1 THEN
SET ErrorMode = 2;
LET vErrorCode = $(=o); // I know this casuses an internal error
EXIT SCRIPT;
END IF
Hope it helps
Miguel
Hello Scott,
You can use at any time
EXIT SCRIPT;
I'd set a variable and depending on the conditions you want, check in the script from time to time the variable. If the variable is equal to 1, then exit script, otherwise, keep executing the script.
Hope that helps!
I am aware of the exit script command, but that will stop the script without producing an error. I am wondering if there is a way to have the script execution "fail", not just quit.
(Side note, how would you put that exit script command in the middle of an if statement?)
Hi,
Something like this maybe?
Table:
LOAD * INLINE [
F1, F2
A1, B1
A2, B2
A3, B3
];
LET vScriptStatus = NoOfRows('Table');
// Your condition here
IF $(vScriptStatus) > 1 THEN
SET ErrorMode = 2;
LET vErrorCode = $(=o); // I know this casuses an internal error
EXIT SCRIPT;
END IF
Hope it helps
Miguel
Miguel,that $(=0) line worked great. You're the man.
Thanks,
Scott
Thanks Scott.
I've set that on purpose, but any other syntax error would result on the script failing, too
XET vErrorCode = 1; // XET doesn't exists in QlikView
The hard part here is to set the condition, making the script to fail is quite the simple part, in my view.
Regards.
Thanks @Miguel_Angel_Baeyens your solution works. The other solution that is proposed above with the new updates doesn´t work propertly.
XET vErrorCode = $(=o);