Post Reply 
Type control
03-14-2015, 09:49 AM (This post was last modified: 03-14-2015 09:53 AM by Han.)
Post: #27
RE: Type control
(03-13-2015 10:39 PM)salvomic Wrote:  Han,
so it goes better:

Code:

EXPORT ANOVA(a)
...
BEGIN
CASE
IF (SIZE(a)==0) THEN a:=0.05; END;
IF (TYPE(a)<>0) THEN ANOVA_help(); RETURN("Usage: ANOVA(a)");  END;
IF (a <=0 OR a>= 1) THEN RETURN("Significance level must be > 0 AND <1"); END;
DEFAULT
END; // case
...

I control that "a" be a number (or give the user a function with help), and if it's a number that its value be in the interval.
But SIZE(a)==0 still doesn't work.
I thought to make "a" parameter option, but I don't remember if it's possible in EXPORT myfunction()... or not.
i.e. EXPORT ANOVA(a:=0.05) doesn't work.

Salvo

It appears I misunderstood you, then. If you want to have a sequence of control flow in which you add more conditions that must be met, then you need to nest your if statements:

Code:
IF (TYPE(a)<>0) THEN
    ANOVA_help(); RETURN("Usage: ANOVA(a)"); 
ELSE
    IF (a <=0 OR a>= 1) THEN
      RETURN("Significance level must be > 0 AND <1");
    ELSE
    ... (rest of your code here)
    END;
END;

There's no point to checking the size of 'a' since multiple arguments in Home view would produce an argument count error (no list behavior like in CAS view) as your program only specifies one argument (which must be given in order for the program to even run).

Non-CAS programs cannot be "overloaded" to handle both cases in which an argument is passed, or when no arguments are passed. You have to specify one or the other. This is why the SIZE(a)==0 check is redundant. Just to be clear, this is regarding the behavior of a non-CAS program.

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


Messages In This Thread
Type control - salvomic - 02-22-2015, 03:42 PM
RE: Type control - Han - 02-22-2015, 04:37 PM
RE: Type control - salvomic - 02-22-2015, 04:46 PM
RE: Type control - Joe Horn - 02-22-2015, 08:47 PM
RE: Type control - salvomic - 02-22-2015, 08:52 PM
RE: Type control - Joe Horn - 02-23-2015, 04:17 AM
RE: Type control - salvomic - 02-23-2015, 08:31 AM
RE: Type control - toml_12953 - 02-23-2015, 04:52 PM
RE: Type control - salvomic - 02-23-2015, 05:01 PM
RE: Type control - Joe Horn - 02-23-2015, 11:40 PM
RE: Type control - salvomic - 02-23-2015, 04:51 PM
RE: Type control - Han - 02-23-2015, 05:10 PM
RE: Type control - salvomic - 02-23-2015, 05:40 PM
RE: Type control - Han - 02-23-2015, 07:18 PM
RE: Type control - salvomic - 02-23-2015, 07:29 PM
RE: Type control - salvomic - 03-12-2015, 09:59 AM
RE: Type control - Han - 03-13-2015, 03:04 PM
RE: Type control - salvomic - 03-13-2015, 03:18 PM
RE: Type control - Han - 03-13-2015, 06:14 PM
RE: Type control - salvomic - 03-13-2015, 06:29 PM
RE: Type control - Han - 03-13-2015, 06:34 PM
RE: Type control - salvomic - 03-13-2015, 06:44 PM
RE: Type control - salvomic - 03-13-2015, 10:39 PM
RE: Type control - Han - 03-14-2015 09:49 AM
RE: Type control - salvomic - 03-14-2015, 10:00 AM
RE: Type control - Angus - 02-24-2015, 06:28 AM
RE: Type control - salvomic - 02-24-2015, 06:34 AM
RE: Type control - Joe Horn - 02-25-2015, 05:52 AM



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