Re: get_key Processing

new topic     » goto parent     » topic index » view thread      » older message » newer message

Try this. You might need to change the include reference to a different directory to make sure the program finds console.e.

include ../../../eu405/include/std/console.e
-- prompt the user for his command  
    clear_screen()  
    integer SCREEN = 1 
    puts(SCREEN, "Simple TC ARES Database\n")  
    object command  
	while 1 do  
		puts(SCREEN,"\n(a)dd, (c)ount, (d)elete, (e)dit, (f)ind, (l)ist, (p)rint, (r)eport, (q)uit: ")  
--		while 1 do	   
--			integer code = get_key()  
			integer code = wait_key()  
			if code != -1 then  
--				command = 'Z'  
				command = code 
				if code = 65 or code = 97 then  
					command = 'A'  
				elsif code = 67 or code = 99 then  
					command = 'C'  
				elsif code = 68 or code = 100 then  
					command = 'D'  
				elsif code = 69 or code = 101 then  
					command = 'E'  
				elsif code = 70 or code = 102 then  
					command = 'F'  
				elsif code = 76 or code = 108 then  
					command = 'L'  
				elsif code = 80 or code = 112 then  
					command = 'P'  
				elsif code = 82 or code = 114 then  
					command = 'R'  
				elsif code = 81 or code = 113 then  
					command = 'Q'  
				end if  
			end if  
--		end while  
		if command = 'A' then  
--		        add()  
			puts(SCREEN, "\n\nValid Command:  " & command & "\n")  
		elsif command= 'C' then  
--		        show_count(SCREEN)  
			puts(SCREEN, "\n\nValid Command:  " & command & "\n")  
		elsif command = 'D' then  
--		        delete()  
			puts(SCREEN, "\n\nValid Command:  " & command & "\n")  
		elsif command = 'E' then  
--		        edit_record()  
			puts(SCREEN, "\n\nValid Command:  " & command & "\n")  
		elsif command = 'F' then  
--		        find_name()  
			puts(SCREEN, "\n\nValid Command:  " & command & "\n")  
		elsif command = 'Q' then  
		        exit  
			puts(SCREEN, "\n\nValid Command:  " & command & "\n")  
		elsif command = 'R' then  
--		        report(SCREEN)  
			puts(SCREEN, "\n\nValid Command:  " & command & "\n")  
		elsif command = 'L' then  
--		        list(SCREEN)  
			puts(SCREEN, "\n\nValid Command:  " & command & "\n")  
		elsif command = 'P' then  
--		        printer = open("PRN", "w")  
			puts(SCREEN, "\n\nValid Command:  " & command & "\n")  
--			if printer = -1 then  
--				puts(SCREEN, "Can't open printer device\n")  
--			else  
--				list(printer)  
--				puts(printer, FORM_FEED)  
--				close(printer)  
--			end if  
		else  
			puts(SCREEN, "\n\nInvalid Command:  " & command & "\n")  
		end if  
    end while  

mike

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu