Hi All,

I have the subroutine as follows, if I type any number other than 0 thru 7
it's fine, 
but if i give a string or a char as an input it of course will not function
correctly.

What can I put in the first if statement to reject characters, I was
thinking about
an unless statement, but I dont know...

Thanks for any help :)

Barry
===========================================

# This subroutine calls the main user menu and refreshes the screen.
sub callMenu
{
        system($clearScreen);
        print
"===========================================================================
=====\n";
        print "System Message:    | $lastMsg\nOpen File:         |
$openFile\nCurrent Directory: | $CWD\n"; 
        print
"===========================================================================
=====\n\n";
        print "Main Menu\n=========\n";
        print "0: Read a File?\n";
        print "1: Display Entire File Contents\n";
        print "2: Display Partial File Contents?\n";
        print "3: Change a Line?\n";
        print "4: Change/Create Directory?\n";
        print "5: Write File?\n";
        print "6: Setup\n";
        print "7: Quit!\n\nInput: ";

        chomp ($menuChoice = <STDIN>);

        if ($menuChoice >= 0 && $menuChoice <= 7) 
        {
                SWITCH:
                {
                        if ($menuChoice == 0) {readFile() ; last SWITCH; }
                        if ($menuChoice == 1) {displayFile() ; last SWITCH;
}
                        if ($menuChoice == 2) {print "Enter Starting Line
Number: "; 
                                                  chomp ($yPos = <STDIN>);
                                                  print "Print to line no:
";
                                                  $yOff = <STDIN>;
                                                  displayFile($yPos, $yOff)
; last SWITCH; }
                        if ($menuChoice == 3) {editFile() ; last SWITCH; }
                        if ($menuChoice == 4) {changeDir() ; last SWITCH; }
                        if ($menuChoice == 5) {writeFile() ; last SWITCH; }
                        if ($menuChoice == 6) {writeConfig() ; last SWITCH;
}
                        if ($menuChoice == 7) {die ("\nUser has Exited\n") ;
last SWITCH; }
                }
        }
        else
        {
                $lastMsg = "That was not a valid choice!";
                callMenu();
        }
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to