Post Reply 
IFERR? Interception of an input error
03-10-2017, 03:08 PM
Post: #6
RE: IFERR? Interception of an input error
(03-10-2017 02:01 PM)EdDereDdE Wrote:  
PHP Code:
is_numeric(H)
BEGIN
   LOCAL c
num := 0;
   FOR 
c FROM 1 TO DIM(H) DO
      
num := POS({47,48,49,50, ..., 57},ASC(H(c)));
      IF 
num THEN CONTINUE; END;
   
END;
   RETURN 
num;
END

There is a bug in your code. Num would be non-zero as long as the last character is numeric. Your IF statement should be: IF (num == 0) THEN RETURN(0); END;

There is no need for CONTINUE, since there is no code to skip after the IF statement. In fact, the current IF statement doesn't actually do anything when you trace the logic.

Also, as an alternative to POS(), you could use: num:=(ASC(H(c)) > 46) AND (ASC(H(c)) < 58);

(The latter suggestion is only pertinent for speed, and when testing for a larger range since POS() could in theory check all the way to the last item in the list.)

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: IFERR? Interception of an input error - Han - 03-10-2017 03:08 PM



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