[Scilab-users] case control statement
Rafael Guerra
jrafaelbguerra at hotmail.com
Sun Jan 22 19:18:10 CET 2017
Schlumberger-Private
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>
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170122/f85e8086/attachment.htm>
More information about the users
mailing list