Revision: 66542
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 21, 2014 05:08 by lalzy
Initial Code
;;;; Input focused, anything the user supplies ;;; Input Checkers (defun interface_input_check (input interface-list) "Check if the interface selected is a valid interface" (if (numberp input) (progn (setf input (- input 1)) (if (< input 0) 'exit (if (nth input interface-list) (nth input interface-list) 'invalid))) 'invalid)) (defun menu_input_check (input arg-list) "Returns the function requested, if it doesn't exist returns invalid Arguments: 1 - preset | Used for checking preset listing if not nil" (let* ((preset (car arg-list))) (cond ((equal input 1) 'showMtu) ((equal input 2) 'EditMTU) ((equal input 3) 'CreatePMTU) ((equal input 9) 'settings) (preset ; If extended menu, allow the other functionality (cond ((equal input 4) 'LoadPMTU) ((equal input 5) 'EditPMTU) ((equal input 6) 'DeletePMTU) (t 'invalid))) (t 'invalid)))) (defun settings_input_check (input arg-list) "Check for valid settings-input" (if (equal input 1) 'changeInterface 'invalid)) (defun input_loop (input_checker arg-list) "Input loop to ensure valid option is suplied What option is valid is defined in the input_checker Arguments: Input_checker - Takes a function that knows what input is valid and what isn't arg-list - List of arguments used for the Input_Checker Return: 'exit - if 0 is inputed, it will default to exit retval - The value given by the input_checker" (let* ((input (read)) (retval (funcall input_checker input arg-list))) (cond ((equal input 0) 'exit) ((equal retval 'invalid) (format t "Invalid Input!~%>> ") (input_loop input_checker arg-list)) (t retval))))
Initial URL
Initial Description
Everything that handles user-input.
Initial Title
MTU-Changing program - Input.lisp
Initial Tags
Initial Language
Lisp