[Scilab-Dev] User-Input Validation
Kalyan Chatterjea
kalyan.chatterjea at gmail.com
Thu Apr 16 04:56:37 CEST 2020
Hello,
I have written a simple code for User-Input-Validation. It seems to work.
But for a wrong string input there is the error 4 (Undefined variable:).
Q1. Can this error be hidden?
Q2. Kindly let me know if I should use a better validation code.
Thanks for your help
Kalyan
CODE:
clear
clc
month = 0;
while (month<1 | month>6)
month = input('Please chose your option between 1 and 6: '); if
(type(month)==10) then month=0;end;//10 - represent string
end
select month
case 1
disp("Month is January")
case 2
disp("Month is February")
case 3
disp("Month is March")
case 4
disp("Month is April")
case 5
disp("Month is May")
case 6
disp("Month is June")
else
disp("Wrong Month number")
end
disp(month)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/dev/attachments/20200416/22f347b7/attachment.htm>
More information about the dev
mailing list