Here is a 'console demonstration' to explain the cause of your error:
;; Bind list to 'codelist' symbol
_$
(setq codelist '
("US001" "US253"))("US001" "US253")
;; Add (push) "" to front of list
("" "US001" "US253")
;; Remove (pop) "" from front of list
("US001" "US253")
;; ...Back to where we started
T
;; The result is a list, strcat requires a string
To print the list to file, I would also likely opt for the solution proposed above by MP, using the
vl-prin1-to-string function to convert the list to a string whilst retaining the string delimiters (
vl-prin1-to-string follows the behaviour of the
prin1 function [however returning the string rather than printing it]; note that
vl-princ-to-string would remove such delimiters):
"(\"US001\" \"US253\")"
"(US001 US253)"
Another method is to use the
prin1 function directly:
(princ "\n(setq codelist '" ofil)
(prin1 codelist ofil)
(princ ")" ofil)
In summary, when unsure as to why your code is failing, I would recommend that you step through each evaluated expression to ensure that the expression is returning the value that you expect it to return; as shown above, the Visual LISP IDE Console is ideal for this purpose.