Hi,
I hope someone can help me here, i'm getting really fustrated at this..,
Anyways, i'm tryng to help my brother that his as frustrated as me at making a
program that should manage a fast food restaurant at making deliveries.
The program should take requests of people and place them in a list.
So, what we do is we get the orders of people like this :
(format t "Insert number of Pizzas: ")
(setf num_pizzas (read T NIL NIL))
(if (> num_pizzas 0)
(setf conj-Opedidos (insert(create-Request "P" num_pizzas)conj-Opedidos )))
(format t "~2%~5t ")
(format t "Insert number of hamburgers: ")
(setf num_frangos (read T NIL NIL))
(if (> num_frangos 0)
(setf conj-Opedidos (insert(create-Request "F" num_frangos)conj-Opedidos )))
(format t "~2%~5t ")
(format t "Insert number of desearts: ")
(setf num_sobremesas(read T NIL NIL))
(if (> num_sobremesas 0)
(setf conj-Opedidos (insert(create-Request "S" num_sobremesas)conj-Opedidos )))
(format t "~2%~5t ")
(format t "Insert number of drinks: ")
(setf num_bebidas (read T NIL NIL))
(if (> num_drinks 0)
(setf conj-Opedidos (insert(create-Request "B" num_drinks)conj-Opedidos )))
After inserting some values the conj-Opedidos looks like this :
(("P" 6) ("F" 6) ("S" 6) ("B" 6))
All good,
After this we ask to what area the delivery should be made :
(format t "~2%~5t ")
(format t "Code Area? (A, B ou C?) ")
(setf area (read T NIL NIL))
(if (or (string-equal area "A") (string-equal area "B") (string-equal area "C")) (return)))
And with this, we feed all the results to another list :
(setf conj-encomendas (insert(create-Package conj-Opedidos area) conj-encomendas )))
In the end, conj-encomendas looks like this :
(((("P" 8) ("F" 8) ("S" 8) ("B" 8)) B))
Once again, all good, we have the food orders and the area code all in one block.
Now the problem is that, when running the code again, instead of adding another block to the list, like this :
(((("P" 8) ("F" 8) ("S" 8) ("B" 8)) B))((("P" 4) ("F" 3) ("S" 2) ("B" 1)) A)))
He gives this error :
1[4]: (Create-Package (("P" 6) ("F" 6) ("S" 6) ("B" 6)) A)
1[4]: returned ((("P" 6) ("F" 6) ("S" 6) ("B" 6)) A)
Error: EXCL::STRING1 argument should be a string
[condition type: PROGRAM-ERROR]
0[4]: returned-by-throwing :POP 0
My guess is that this setf is wrong, but i tried so many diferent things and i just can't get this working
no matter what i do..,
Any ideias on what could be wrong ?
thank you very much...
Auxiliary structures
The list conj-Opedidos is defined like this :
(defun create-Request (oTipo oQuantidade)
(list oTipo oQuantidade))
(defun oTipo (opedido)
(first opedido))
(defun oQuantidade (opedido)
(second opedido))
(setf conj-Opedidos nil)
The list conj-encomendas..
(defun Create-Package (ped_pratos zona)
(list ped_pratos zona))
(defun ped_pratos (encomenda)
(first encomenda))
(defun zona (encomenda)
(second encomenda))
insert
------
(defun insert(n c)
(if (null c)
(list n)
(if (string-equal (first n)(first (first c)))
c
(cons (first c)(insere n (rest c))))))