Problems with scan function

#1
Hi,

I am having problems with scan() function, using it to get values from console.
The above code doesn't work properly. It doesn't stop after scan() function.
Is there anything wrong?, can anybody help me?


funent <- function(){
val <- scan(,,1)
return(as.character(val))
}

print("Seleccione: 1. consulta, 2.cirugia")
tipo <- funent()
while((tipo < 1 | tipo >2 )){
if (tipo < 1 | tipo >2 ) {
print("Introduzca 1(consulta) o 2(cirugia)")
tipo <- funent()
}
}