Korn shell can kiss my ass.
airbornflght
Houston, TX Icrontian
Ok. I'm doing some programming (scripting..) inside of ksh. now when I was assigned this little project I laughed, thinking I'd have it done in 15 minutes..
Here is the assignment. Write a program that shows a menu with two choices, play, or quit. Then from there the program chooses a random number from 1-20 and then the user guesses until correct. From there the user must be offered the chance to replay. Otherwise just quit.
My problem is with korn shell's control structures and operators. They are becoming a pain in my ass. I'm starting to get mad because I keep getting errors. I'm way too used to Java.
Here is what I have, granted it won't run.
This is all fairly sloppy but I'm trying to get it to work and it's not happening. the program will run right up until it tries to decide a case it says: Can someone help me get the cases working. good lord if I could do that then this program would be pretty much wrapped up.
Here is the assignment. Write a program that shows a menu with two choices, play, or quit. Then from there the program chooses a random number from 1-20 and then the user guesses until correct. From there the user must be offered the chance to replay. Otherwise just quit.
My problem is with korn shell's control structures and operators. They are becoming a pain in my ass. I'm starting to get mad because I keep getting errors. I'm way too used to Java.
Here is what I have, granted it won't run.
menu=0 x=0 while ((menu != 1 & menu != 2 & menu != 3 )) do clear screen print "********************" print "Welcome:\n\t1: Play game\n\t2: How To\n\t3: Exit" if ((menu != 1 & menu != 2 & menu != 3 & x > 0)) then print "\nInput must be 1, 2, or 3!" fi print "Enter A Choice: \c" read menu print "\n*******************" ((x=x+1)) done clear screen case $menu in 1) #Pick Random Number #check if input equals q, if so exit #check if input is in range, if not get input again; alert user #check if input is equal to number, if not get input again; alert user #offer user chance to play again, if not exit #return to menu 2) print "The computer chooses a random number" print "It is between one and twenty" print "Try to guess that number" #return to menu 3) exit
This is all fairly sloppy but I'm trying to get it to work and it's not happening. the program will run right up until it tries to decide a case it says: Can someone help me get the cases working. good lord if I could do that then this program would be pretty much wrapped up.
syntax error: 'case' unmatched
0
Comments
so should be while (($menu != 1 & $menu != 2 & $menu != 3 ))
as should if (($menu != 1 & $menu != 2 & $menu != 3 & x > 0))