Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Darth.Severus

#1
In a script I run: (read-file <path>) and (parse str "/n") to get a list with the content of a file parsed in lines into the symbol input-list. Then I run following code:


(dolist (temp input-list)
(when (not (or
(starts-with temp "#")
(starts-with temp "t")))
(setq temp (replace " " temp "&nbsp;"))
(push (string temp "<br>") result-list -1))
(when (starts-with temp "#")
(push (heading temp) result-list -1)))


It does what it should do, but not with the first line. It has no (exit) function at the end, so I can look what is in input-list. The first line is "### whatever" and e.g. the fifth is "### whatever-again". But it applies the first (when) to the first line and the second (when) function to all the others starting with "#". This is completely crazy.



Linux my-notebook 3.14-0.bpo.2-686-pae #1 SMP Debian 3.14.15-2~bpo70+1 (2014-08-21) i686 GNU/Linux

newLISP v.10.6.2 32-bit on Linux IPv4/6 UTF-8 libffi
#2
newLISP in the real world / man pages for newLisp
April 10, 2013, 07:29:48 AM
I while ago I wondered, why there are no manpages for newLisp functions like for programms in Linux. Cause I thought this would really be helpful, I created them on my own. Ripped the descriptions from the manual and created a context with the name 'man'. I added a line to newlisp console, so that it is always loaded.

So (man "append") prints the description of append into the console.



I think it would be helpful, especially for beginners if something like that would become part of newlisp as standard or at least of nls.lsp.

Put the line (load "/home/yourpath/man.lsp") into nls.lsp to load it automatically, and put man.lsp also into "/usr/share/newlisp/modules" or the correct path in your OS, then (module man.lsp)



"man.lsp" is the context with a definition, if loaded (man "something") works. The function replace is missing in man.lsp, cause I couldn't load it with that entry inside. "manGen.lsp" is the ripping programm.



The files are here, only man.lsp is needed, manGen.lsp is for making a new version.

https://github.com/DarthSeverus/newLisp">https://github.com/DarthSeverus/newLisp
#3
I'm using some code in a program, to get the links of a website incl. subpages. But it's not working, I often get "ERR: HTTP document empty". I puted a until loop into the code, so that it tries it several times, always after some minutes. My fist thougth was, I'm blocked by the server, but this seems not to be the case. If I open a newlist shell and write (get-url url) I get the site, while I still have the same IP.



(define (pick-links url)
(setq page (get-url url))
(println (1 20 page)) ; testing
(write-file "page" page); also testing
(until (not (starts-with page "ERR: HTTP document empty"))
(and (sleep 600000) (setq page (get-url url))))
(setq linklist (join (find-all "<a href=([^>]+)>([^>]*)</a>" page) "<br>n"))
        (setq linklist
(replace {"} linklist "`")) ;"
(setq parsedlist
(parse linklist "n"))  
(setq page nil) )
#4
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:
Quote
(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.
Quote
(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:
Quote
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.
#5
Hi,

I want to have .lsp files to be executable by click, like in windows. Without making a real executable out of it by using link.lsp.

I'm using roxterm and Antix-Linux (Debian/Mepis) and I am realativly new to linux. I'm using roxterm -e newlisp "$@ as "set run action". My problem now is that it prints


Quoteit works!newLISP v.10.3.4 on Linux IPv4/6 UTF-8, execute 'newlisp -h' for more info.


#!/usr/bin/newlisp
(print "it works!")


Regards,

DS