commit 789dcd052a85b45def4fbcfb48631bda03131e3a
Author: Simon Watson <spw01@protonmail.com>
Date: Sat Jul 17 19:35:34 2021 -0400
Basic PoC working
diff --git a/fin-lisp.lisp b/fin-lisp.lisp
index 87fad93..08fd4ca 100644
--- a/fin-lisp.lisp
+++ b/fin-lisp.lisp
@@ -11,6 +11,9 @@
;;; and the value is the monthly expenses hash
(defvar *records* (make-hash-table :test 'equalp))
+(defun reset-records ()
+ (setf *records* (make-hash-table :test 'equalp)))
+
;; Called like: (add-month '202107)
(defun add-month (month-key)
(setf (gethash month-key *records*) (make-hash-table :test 'equalp))
@@ -32,10 +35,6 @@
(if (gethash month *records*)
(let ((innerhash (gethash month *records*))
(exp-l (prompt-for-expense)))
- (format t "Expense name is: ~a" (first exp-l))
- (terpri)
- (format t "Expense value is: ~a"(second exp-l))
- (terpri)
(setf (gethash (first exp-l) innerhash) (second exp-l)))
;;NIL))
(add-expense-to-month (add-month month))))
@@ -66,11 +65,26 @@
;; Entry point
(defun main ()
- (format t "Available options:")(terpri)
- (format t "1. Enter expense")(terpri)
- (format t "2. Display month")(terpri)
- (format t "3. Write records")(terpri)
+ (format t "Available options:~C" #\linefeed)
+ (format t "1. Enter expense~C" #\linefeed)
+ (format t "2. Display month~C" #\linefeed)
+ (format t "3. Write records~C" #\linefeed)
+ (format t "4. Read records~C" #\linefeed)
+ (format t "5. Quit~C" #\linefeed)
(let
((answer (prompt-read "Select an option")))
- answer))
-
+ (if (string= answer "1")
+ (add-expense-to-month
+ (read-from-string
+ (prompt-read "Enter month"))))
+ (if (string= answer "2")
+ (dump-month
+ (read-from-string
+ (prompt-read "Enter month"))))
+ (if (string= answer "3")
+ (serialize-records (prompt-read "Enter filename")))
+ (if (string= answer "4")
+ (deserialize-records (prompt-read "Enter filename")))
+ (if (string= answer "5")
+ (quit)))
+ (main))