I wrote a function to query a small database program I'm writing for school. This function searches by name. When I run the function by itself it works. When I run it within the menu it does not work (it returns NIL). Here is everything relevant:
(defun prompt-read (prompt)
(format *query-io* "~a: " prompt)
(force-output *query-io*)
(read-line *query-io*))
(defun search-name (name)
(remove-if-not
#'(lambda (cat) (equal (getf cat :name) name)) *db*))
(defun input-name ()
(search-name
(prompt-read "Name")))
(defun search-menu ()
(print "1) Search Name")
(print "2) Search Color")
(print "3) Search Min. Weight")
(print "4) Search Min. Experience")
(print "5) Search Min. Length")
(setf choose (read))
(cond ((= choose 1)(input-name))
((= choose 2)(print "Color"))
((= choose 3)(print "Weight"))
((= choose 4)(print "XP"))
((= choose 5)(print "Color"))
)
NIL
)
Right now I am only working on getting the name search working, the rest of the menu is just placeholders. When I run "input-name" (which uses search-name) by itself it returns the correct result. When I try the first option from the search-menu (which also runs "input-name") it returns NIL. I am wondering why when I run it by itself works but not when used with that menu. If anybody needs any other information feel free to ask. I will try my best to provide it. Also, I am a beginner so please forgive me.