I'm having problems / confusion when using dotree in a database program.
dotree either doesn't work or is of little or no value. The simplified working program below creates, lists, and deletes database tree items using dotree.
Code: Select all
(new Tree 'pet-db)
(pet-db "dog" "King")
(pet-db "cat" "Fluffy")
(pet-db "hamster" "Sam")
(pet-db "fish" "Goldy")
(println "---> show the database")
(println (pet-db))
(println "--> list items")
; (dotree (pet pet-db) (println pet " -> " (pet) )) ; 1. Error?
; (dotree (pet pet-db true) (println pet " -> " (eval pet) )) ; 2, Hang and crash!
(dotree (pet pet-db) (println pet " -> " (eval pet) ))
(println "---> delete ttems")
; (dotree (pet pet-db) (println pet " -> " (pet nil) )) ; 1. Error?
; (dotree (pet pet-db true) (println pet " -> " ((prefix pet) (1 (string (term pet))) nil) )) ; 2. Hang and crash!
(dotree (pet pet-db) (println pet " -> " ((prefix pet) (1 (string (term pet))) nil) ))
(println "--> show database")
(println (pet-db))
(exit)
1. Using the what I expected (pet) or (pet nil) tree access forms cause an invalid function error. After much experimentation, using (eval pet) and my patent pending "messy code" ((prefix pet) (1 (string (term pet))) nil) works, but then...
2 . When trying to only list the tree items using dotree with the true flag, it somehow causes a hang and crash on Win 7. This is like a run away system memory crash of the interpreter, and not an error condition.
What is the proper way to scan through all the items in a database tree when simply trying to update and or delete itens?
dotree, or not to dotree that is the (my) question... ;>)
-- xytroxon