[Scilab-users] case control statement
Rafael Guerra
jrafaelbguerra at hotmail.com
Sun Jan 22 21:27:38 CET 2017
Apologies for previous Outlook emails with company info classification - will remove this in the future.
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Rafael Guerra
Sent: Sunday, January 22, 2017 7:38 PM
To: Users mailing list for Scilab <users at lists.scilab.org>
Subject: Re: [Scilab-users] case control statement
Well, it selects only %true expressions, actually I believe it selects only the first case true expression encountered, so the cases need to be exclusive. You can test and let us know
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Claus Futtrup
Sent: Sunday, January 22, 2017 7:31 PM
To: users at lists.scilab.org<mailto:users at lists.scilab.org>
Subject: Re: [Scilab-users] case control statement
Hi Rafael
Interesting... So I don't need to select anything, I can just do case model== something. (Or maybe select initializes the case ... but it looks to me like you're not really using select for anything)
/Claus
On 22-01-2017 19:18, Rafael Guerra wrote:
Hi Claus,
Check this code out:
// START OF (UGLY) CASE
loop= %t;
while loop
printf("\n")
str = input("Enter number (1-7) or 0 to exit: n=","string");
n = evstr(str);
select %t
case n== 2
printf("single choice...\n");
case n== 5
printf("single choice...\n");
case or(n==[1 3 4])
printf("n=%i --> multiple choice#1:\n",n);
case or(n==[6,7])
printf("n=%i --> multiple choice#2:\n",n);
case n==0
printf("Bye...\n");
loop=%f;
end
end
// END OF CASE
Regards,
Rafael
-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Claus Futtrup
Sent: Sunday, January 22, 2017 3:59 PM
To: International users mailing list for Scilab. <users at lists.scilab.org><mailto:users at lists.scilab.org>
Subject: [Scilab-users] case control statement
Hi there
I'd like to use the "case" control statement to select a few options.
I'm wondering, is it possible for a case to have multiple options, I
mean like this:
select model
case 1,3,4 then
do something
case 2 then
do something
case 5 then
do something
end
Could I define [1 3 4] as a group of options and ask "CASE IN GROUP" ...
or how would I go about and implement this?
Best regards,
Claus
_______________________________________________
users mailing list
users at lists.scilab.org<mailto:users at lists.scilab.org>
http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170122/c7b05394/attachment.htm>
More information about the users
mailing list