[Scilab-Dev] User-Input Validation

kalyansg Kalyan.Chatterjea at gmail.com
Thu Apr 16 08:49:00 CEST 2020


I think a better code would be:

clear
clc
month = 0;

while (month<1 | month>6)
 
    month = input('Please chose your option between 1 and 6: ', "string")
    month=strtod(month)
    if (isnan(month)) then month = 0;end
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)




--
Sent from: http://mailinglists.scilab.org/Scilab-developers-Mailing-Lists-Archives-f2574944.html



More information about the dev mailing list