Below is my code which is througing the error. Can somebody please look into this and let me know what is getting wrong in my code. Wrote this code in common lisp but while compiling i am getting the error as mentioned in the question. Not sure what is giving me the error. If somebody, can let me know where i am going wrong? I tried to figure, but was not able to do that. If, somebody can help.
(defun validate-arn-data (tokens)
(declare (special *rule-loading*))
(when (typep tokens 'rel-errors)
(setq tokens (rel-errors-correct-tokens tokens)))
(if (and tokens (not *rule-loading*))
(let ((arn-num nil)
(rtn-msg nil)
(processed-rtn-msg nil)
(start nil)
(end nil)
(transaction-id nil)
(transac-id-length nil)
(pon-tokens nil)
(pon-value nil)
(pon-length nil)
(rtn nil)
(errors (make-rel-errors))
)
(dolist (to tokens)
(setq arn-num (so-token-value to))
(if (numeric-string? arn-num)
(when arn-num
(setq rtn-msg (call-dispatch-services arn-num))
(setq processed-rtn-msg (process-dispatch-services-reply rtn-msg))
(when processed-rtn-msg
(when (setq start (search "appointmentOrderId" rtn-msg))
(setq end (search "," (subseq rtn-msg start)))
(setq transaction-id (subseq rtn-msg (+ start 23) (+ start (- end 1))))
(setq rtn t)
(cond ((or (equal *so-entry-appl* " ")
(equal *so-entry-appl* "B")
(equal *so-entry-appl* "L")
(equal *so-entry-appl* "U")
(equal *so-entry-appl* "V"))
(setq transac-id-length (length transaction-id))
(setq pon-tokens (find-matching-tokens "PON"))
(cond ((not (equal pon-tokens nil))
(dolist (to-pon pon-tokens)
(setq pon-value (so-token-value to-pon))
(setq pon-length (length pon-value))
(if (<= (+ pon-length 1) (length transaction-id))
(unless (equal pon-value (subseq transaction-id 1 (+ pon-length 1)))
(if (>= transac-id-length 8)
(progn
(setq transaction-id (subseq transaction-id (- transac-id-length 8) transac-id-length))
(unless (equal transaction-id *so-order-number*)
(setq rtn nil)))
(setq rtn nil))
(unless rtn
(setq *more-long-error-msg* (concatenate 'simple-string
"ORDER ID MISMATCH ")))))))
(t nil))
((equal *so-entry-appl* "F")
(setq pon-tokens (find-matching-tokens "PON"))
(dolist (to-pon pon-tokens)
(setq pon-value (so-token-value to-pon))
(setq pon-length (length pon-value))
(if (<= (+ pon-length 1) (length transaction-id))
(unless (equal pon-value (subseq transaction-id 1 (+ pon-length 1)))
(setq rtn nil))
(setq rtn nil))
(unless rtn
(setq *more-long-error-msg* (concatenate 'simple-string
"ORDER ID MISMATCH ")))))
(t
(setq rtn t)))))
(if rtn
(push to (rel-errors-correct-tokens errors))
(push to (rel-errors-error-tokens errors))))
(push to (rel-errors-error-tokens errors))))
errors)
t)))
The error is below:
(load (compile-file "/home/raymond-arn.lisp"))
;;; Compiling file /home/ac86208/raymond-arn.lisp ...
;;; Safety = 3, Speed = 1, Space = 1, Float = 1, Interruptible = 1
;;; Compilation speed = 1, Debug = 2, Fixnum safety = 3
;;; Source level debugging is on
;;; Source file recording is on
;;; Cross referencing is on
; (TOP-LEVEL-FORM 0)
**++++ Error in VALIDATE-ARN-DATA:
Illegal car (EQUAL *SO-ENTRY-APPL* "F") in compound form ((EQUAL *SO-ENTRY-APPL* "F") (SETQ PON-TOKENS (FIND-MATCHING-TOKENS "PON")) (DOLIST (TO-PON PON-TOKENS) (SETQ PON-VALUE (SO-TOKEN-VALUE TO-PON)) (SETQ PON-LENGTH (LENGTH PON-VALUE)) (IF (<= (+ PON-LENGTH 1) (LENGTH TRANSACTION-ID)) (UNLESS (EQUAL PON-VALUE (SUBSEQ TRANSACTION-ID 1 (+ PON-LENGTH 1))) (SETQ RTN NIL)) (SETQ RTN NIL)) (UNLESS RTN (SETQ *MORE-LONG-ERROR-MSG* (CONCATENATE (QUOTE SIMPLE-STRING) "ORDER ID MISMATCH WITH FTS-ICADS ORDER "))))).
;; Processing Cross Reference Information
; *** 1 error detected, no fasl file produced.
!!!!!Wrote error log to /home/logs/LispWorks/lispworks-8-0-0-amd64-linux-log at 2023/06/05 08:29:37
Error: Argument NIL is not of type PATHNAME, STRING, or FILE-STREAM.
Your cond
s are nested, maybe you have to clarify which condition apply to which cond. Here is a modified version:
(defun validate-arn-data (tokens)
(declare (special *rule-loading*))
(when (typep tokens 'rel-errors)
(setq tokens (rel-errors-correct-tokens tokens)))
(if (and tokens (not *rule-loading*))
(let ((arn-num nil)
(rtn-msg nil)
(processed-rtn-msg nil)
(start nil)
(end nil)
(transaction-id nil)
(transac-id-length nil)
(pon-tokens nil)
(pon-value nil)
(pon-length nil)
(rtn nil)
(errors (make-rel-errors))
)
(dolist (to tokens)
(setq arn-num (so-token-value to))
(if (numeric-string? arn-num)
(when arn-num
(setq rtn-msg (call-dispatch-services arn-num))
(setq processed-rtn-msg (process-dispatch-services-reply rtn-msg))
(when processed-rtn-msg
(when (setq start (search "appointmentOrderId" rtn-msg))
(setq end (search "," (subseq rtn-msg start)))
(setq transaction-id (subseq rtn-msg (+ start 23) (+ start (- end 1))))
(setq rtn t)
(cond ((or (equal *so-entry-appl* " ")
(equal *so-entry-appl* "B")
(equal *so-entry-appl* "L")
(equal *so-entry-appl* "U")
(equal *so-entry-appl* "V"))
(setq transac-id-length (length transaction-id))
(setq pon-tokens (find-matching-tokens "PON"))
(cond ((not (equal pon-tokens nil))
(dolist (to-pon pon-tokens)
(setq pon-value (so-token-value to-pon))
(setq pon-length (length pon-value))
(if (<= (+ pon-length 1) (length transaction-id))
(unless (equal pon-value (subseq transaction-id 1 (+ pon-length 1)))
(if (>= transac-id-length 8)
(progn
(setq transaction-id (subseq transaction-id (- transac-id-length 8) transac-id-length))
(unless (equal transaction-id *so-order-number*)
(setq rtn nil)))
(setq rtn nil))
(unless rtn
(setq *more-long-error-msg* (concatenate 'simple-string
"ORDER ID MISMATCH ")))))))
(t nil)))
((equal *so-entry-appl* "F")
(setq pon-tokens (find-matching-tokens "PON"))
(dolist (to-pon pon-tokens)
(setq pon-value (so-token-value to-pon))
(setq pon-length (length pon-value))
(if (<= (+ pon-length 1) (length transaction-id))
(unless (equal pon-value (subseq transaction-id 1 (+ pon-length 1)))
(setq rtn nil))
(setq rtn nil))
(unless rtn
(setq *more-long-error-msg* (concatenate 'simple-string
"ORDER ID MISMATCH ")))))
(t
(setq rtn t))))
(if rtn
(push to (rel-errors-correct-tokens errors))
(push to (rel-errors-error-tokens errors))))
(push to (rel-errors-error-tokens errors))))
errors)
t)))
To simplify your code and avoid those problems, you may try to encapsulate cond
conditions and cond forms into their own function.