DickBaldwin
04-10-2007, 11:42 AM
I would like to emulate the following C++ code in Alice:
//=======================================
void doSomething(){
char temp = 0;
cout << "Enter an upper-case letter: ";
cin >> temp;
while(!((temp >= 'A') && (temp <= 'Z'))){
//Outside allowable character range
cout << "Bad input" << endl;
cout << "Enter an upper-case letter: ";
cin >> temp;
}//end while loop
//End end loop structure
//Good input, display msg and terminate.
cout << "Thanks for the " << temp << endl;
}//end doSomething function
//====================================
Since there is no char type in Alice, and apparently no built-in functions to compare strings, the solution is not obvious to me.
Any suggestions would be appreciated.
Thanks,
Dick Baldwin
//=======================================
void doSomething(){
char temp = 0;
cout << "Enter an upper-case letter: ";
cin >> temp;
while(!((temp >= 'A') && (temp <= 'Z'))){
//Outside allowable character range
cout << "Bad input" << endl;
cout << "Enter an upper-case letter: ";
cin >> temp;
}//end while loop
//End end loop structure
//Good input, display msg and terminate.
cout << "Thanks for the " << temp << endl;
}//end doSomething function
//====================================
Since there is no char type in Alice, and apparently no built-in functions to compare strings, the solution is not obvious to me.
Any suggestions would be appreciated.
Thanks,
Dick Baldwin