This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Write A menu for dictionary

5 posts · 6736 views

Hello every body ,
Actually I am very beginner in lisp and I have a home work to make some thing like dictionary .
I should make a menu that gives the user some choices like add new word or delete it or translate it .
I write this in txt file :

( loop
(print "==================================================================")
(print "Please Select One of This Choises ")
(print "==================================================================")
(print "==================================================================")
(print "1- translate ")
(print "2- add word ")
(print "3- delete word")
(print "0- exit")
(setf i (read))
(if (= i 1) (call translate) )
(if (= i 2) (call add))
(if (= i 3) (call delete))
(if (= i 4) (return "Good Bye"))
)

then when I load it like this ;
(load "t.lsp")
it write the print commands but at the end give this result :
"unexpected end of input stream "

please would you help me in this error
thank you

Re: Write A menu for dictionary

I tried you code with clisp and it does not fail in the manner you describe.
I'm thinking you might use a different implementation that demands a line feed in the last line and you got none perhaps?

Other than that you may want to separate parts of your code in functions and even put the loop into a function so that you can load and test your parts individually. It makes debugging/testing easier.

br,
Syl
I'm the author of two useless languages that uses BF as target machine.
Currently I'm planning a Scheme compiler :p

Re: Write A menu for dictionary

thanks alot

Re: Write A menu for dictionary

Define this function

(defun menu ()
(print "==================================================================")
(print "Please Select One of This Choises ")
(print "==================================================================")
(print "==================================================================")
(print "1- translate ")
(print "2- add word ")
(print "3- delete word")
(print "0- exit")
(setf i (read))
(cond
((if (= i 1) (call translate) ))
((if (= i 2) (call add)) )
((if (= i 3) (call delete)) )
((if (= i 4) (return "Good Bye")) ) )
)

Call it later

(menu)

Re: Write A menu for dictionary

thank you very much .........
it seems good