is AND broken?
10-11-2015, 01:23 AM
Post: #1
 ji3m Member Posts: 149 Joined: Sep 2015
is AND broken?
I have very mysterious problems with the AND function in a program if statement.

The program misbehaves until i remove the AND and use two ifs.

E.e

IF ((expr1) AND (expr2)) THEN ....

fails with bad argument error somewhere in the code.

IF (expr1) THEN
IF (expr2) THEN
......

make the gremlins go away.

Seems odd.

I work with android Prime only for now on my
Galaxy Tab Pro/Note 2
10-11-2015, 05:06 AM
Post: #2
 Han Senior Member Posts: 1,882 Joined: Dec 2013
RE: is AND broken?
(10-11-2015 01:23 AM)ji3m Wrote:  I have very mysterious problems with the AND function in a program if statement.

The program misbehaves until i remove the AND and use two ifs.

E.e

IF ((expr1) AND (expr2)) THEN ....

fails with bad argument error somewhere in the code.

IF (expr1) THEN
IF (expr2) THEN
......

make the gremlins go away.

Seems odd.

You can place a DEBUG; statement right before where you think the error occurs and then run the program and this will pull up the debugger so you can see the real cause.

Graph 3D | QPI | SolveSys
10-11-2015, 05:35 AM (This post was last modified: 10-11-2015 05:35 AM by Didier Lachieze.)
Post: #3
 Didier Lachieze Senior Member Posts: 1,525 Joined: Dec 2013
RE: is AND broken?
This has been discussed here.
10-14-2015, 02:09 AM (This post was last modified: 10-14-2015 02:10 AM by toml_12953.)
Post: #4
 toml_12953 Senior Member Posts: 1,938 Joined: Dec 2013
RE: is AND broken?
(10-11-2015 01:23 AM)ji3m Wrote:  I have very mysterious problems with the AND function in a program if statement.

The program misbehaves until i remove the AND and use two ifs.

E.e

IF ((expr1) AND (expr2)) THEN ....

fails with bad argument error somewhere in the code.

IF (expr1) THEN
IF (expr2) THEN
......

make the gremlins go away.

Seems odd.

If expr2 has an error in it, the second example works because the IF never gets evaluated if the first IF is false. HPPL, as in most forms of BASIC, evaluates all expressions in an AND statement. There's no early exit if the first part of the AND is false.

Example:
Code:
IF 4<2 AND 1/0 >3 THEN <do something here> END;
will fail because 1/0 is illegal.
Code:
 IF 4<2 THEN   IF 1/0>3 THEN     <do something here>   END; END;

will work because the 1/0 never gets evaluated.

Tom L
Cui bono?
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)