(append-file symbol symbol) not working?

Q&A's, tips, howto's
Locked
Darth.Severus
Posts: 14
Joined: Mon Sep 17, 2012 3:28 am

(append-file symbol symbol) not working?

Post by Darth.Severus »

I'm writing a script which takes additional code for the content container from txt files and creates html sites with different content. Now I have a problem.

Stuff like this works:
(append-file aktuell {<div id="center" style="background-color:#EEEEEE;height:800px;width:420px;font-size:0.875em;float:left;">})
(append-file aktuell "\n")
aktuell is a symbol with e.g. index.html ... other.html from a dolist function

But, here is a problem.
(trace true)
(define contentname (chop aktuell 5))
(define contentname (push ".txt" contentname -1))
(change-dir "/home/myUsername/Folder/Content/")
(setq content (read-file contentname))
(change-dir "/home/myUsername/Folder/HTML/")
(append-file aktuell (eval-string (string {(append-file aktuell content)} )))
;; cause (append-file aktuell content) isn't working.
If I use (trace true) like above I get:
ERR: string expected in function append-file : aktuell}
ERR: string expected : (eval-string (string "(append-file aktuell content)"))
ERR: missing argument
Strange to me is also, that it works through the whole list of html file names, but if I don't use (trace true) it crashes and doesn't create more than a uncomplete index.html. So far it was no problem, cause it created the html files correctly if I had "trace true" into the code, but now a have one more error and it may be related to that.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: (append-file symbol symbol) not working?

Post by Lutz »

what is this supposed to do?

Code: Select all

(eval-string (string {(append-file aktuell content)} ))
and what is the 'eval-string' for?

the best would be to decompose the expression and try the parts individually.

Darth.Severus
Posts: 14
Joined: Mon Sep 17, 2012 3:28 am

Re: (append-file symbol symbol) not working?

Post by Darth.Severus »

I tried something with eval-string cause:
;; cause (append-file aktuell content) isn't working.
It was ment this way:
(eval-string (string {(append-file aktuell content)} ))
aktuell is the path and content is the symbol with the content from (setq content (read-file contentname))

I thought append-file isn't accepting (append-file aktuell content), and tried it by using eval-string.

But now it is really working without eval-string.
There was another error, and because I was using the same symbol name several times I was seeking the error at the wrong place and messed up my code there. This was a reminder why not using symbol names again.
the best would be to decompose the expression and try the parts individually.
You're right, from now on I'm gonna check parts of the code in newLisp-edit (GUI). I tried to write that little script by using an editor without syntax highlighting, cause I was switching from WinXP to Linux and had not found a good editor with highlighting so far. I also didn't test parts of the code on their own, just run the full script again and again. Now I've got it, I think. I'm nearly a complete beginner in programming and also in Linux.

Thanks, so far.

Locked