Source language: Translate to:

hpwNewLISP - interface plugin to newLISP

Questions about NeoBook PlugIns

Moderator: Neosoft Support

hpwNewLISP

Postby HPW » Sat Dec 06, 2003 11:33 am

I would made a different approach. Instead of making a big string of a whole file in neobook and push it over the interface, I would do it on the newlisp side.

There I would read one line after another with read-line and put them i a list and check each new line with (not(member ...)) before I put it into the list.

(Double post here and in the newLISP forum)
HPW
 

hpwNewLISP

Postby Sam Cox » Sat Dec 06, 2003 1:13 pm

Hans-Peter,

I took your advice and rewrote the "unique" program as follows.  Now newLISP is doing all of the work.

    SetVar "[LispCode]" "(set 'inFile (open {[PubDir]Data1.txt} {read}))"
    hpwNewLispCall "[PubDir]" "[LispCode]" "[LispResult]"

    SetVar "[LispCode]" "(set 'outFile (open {[PubDir] Data2.txt} {write}))"
    hpwNewLispCall "[PubDir]" "[LispCode]" "[LispResult]"

    hpwFileRead "[PubDir]LispCode.txt" "ALL" "[LispCode]"
    hpwNewLispCall "[PubDir]" "[LispCode]" "[LispResult]"

And here is LISPCODE.TXT.

    (set 'uniqueLines '())
    (while (read-line inFile)
        (if (not (member (current-line) uniqueLines))
            (set 'uniqueLines (append uniqueLines (list (current-line))))))
    (close inFile)
    (map (lambda (aLine) (write-line aLine outFile)) uniqueLines)     ;; see below
    (close outFile)

For the output file to be sorted in addition to being unique, change the line marked "see below" to

    (map (lambda (aLine) (write-line aLine outFile)) (sort uniqueLines))

For the output file to be sorted in reverse order,

    (map (lambda (aLine) (write-line aLine outFile)) (reverse (sort uniqueLines)))

For the purposes of embedding LISP code within a NeoBook shell, it would be nice if I could write:

SetVar "[LispCode]" "   <<< opening quote
(set 'uniqueLines '())
(while (read-line inFile)
   (if (not (member (current-line) uniqueLines))
       (set 'uniqueLines (append uniqueLines (list (current-line))))))
(close inFile)
(map (lambda (aLine) (write-line aLine outFile)) uniqueLines)
(close outFile)
"          <<< closing quote

Added later:

Lutz on the newLISP Forum helped me with the following. Pretty darn slick if you ask me!  If anyone unfamiliar with LISP is interested in knowing how this code works, send me an email or private message on this board with an address to which I can send my detailed notes.

    SetVar "[NL]" "[#13][#10]"
    SetVar "[InFile]" "[PubDir]Data1.txt"
    SetVar "[OutFile]" "[PubDir]Data2.txt"
    SetVar "[LispCode]" "(write-file {[OutFile]} (join (unique (parse (read-file {[InFile]}) {[NL]})) {[NL]}))"
    hpwNewLispCall "[PubDir]" "[LispCode]" "[LispResult]"

Lutz originally used "\r\n" where I now have {[NL]} (two places).  I could not get it to work with the {\r\n} so I substituted [#13][#10].  Notice that within NeoBook I'm using newLISP's alternative string-quoting symbols (left and right braces) instead of double quotes which allows for much easier to embed newLISP coding in NeoBook.

(Edited by Sam Cox at 11:20 am on Dec. 6, 2003)
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

hpwNewLISP

Postby HPW » Sat Dec 06, 2003 2:08 pm

Sam,

Yes that was the idea. 7 lines for the problem are not to bad? I used similar algorithm for parsers at work. Using the newlisp.exe and command-parameters you can pretty automate things. By the way, running not only on WIN-maschines, they run directly under solaris on our host. It is pretty to develop and test under WIN but do daily hard work on production platforms. In newlisp you can check for OS and write the file-format for the platform. But this gets a bit off-topic.

>For the purposes of embedding LISP code within a NeoBook shell, it would be nice if I could write:

That's a question for Dave. ;-)

Of cource it's not really a problem, because I would prefer a extern editor for my lisp, because of syntax-highlighting and paranthesis checking. And we can use the extract-command to embed the source. Or you bind them in hidden objects.
HPW
 

hpwNewLISP

Postby HPW » Sun Dec 07, 2003 10:08 am

Just released hpwNewLISP 1.01:

Features:
Action: hpwNewLispCall - Support for callbacks in return-messages into neoScript!
Support-file: nb_util.lsp with usefull functions. Starts with: (nl2nb-list '("1" "2" "3"))
Demo-file: neoTurtle.lsp with fractal-graphics in neobook powered by newLISP/hpwImage.
Last but not least: newlisp.dll Development version 7.3.16

Demo-pub requires hpwImage-plugin.
HPW
 

hpwNewLISP

Postby HPW » Mon Dec 08, 2003 12:29 pm

Just upload a new hpwNewLISP:

Now includes ported Demo-Lisp of Tower of Hanoi
HPW
 

hpwNewLISP

Postby HPW » Tue Dec 09, 2003 11:27 am

Just upload a new hpwNewLISP zip:

It contains the demo from Sam Cox (Thanks) for calculating roman numbers.

For Hanoi.lsp I have tried to measure the time in newLISP. But I don't know if it is that fast or if the neobook timer just not work as long as the DLL works in the process. I start the timer before calling the plugin and the stop is the first command in the action-string which is started with nbPlayAction.

Maybe Dave can say somthing on this?
HPW
 

hpwNewLISP

Postby HPW » Tue Dec 09, 2003 1:29 pm

Using a newlisp timer function gives about 800-900 milliseconds for generating the Hanoi nb-action string.
HPW
 

hpwNewLISP

Postby HPW » Tue Dec 09, 2003 11:55 pm

Just notice that the latest zip does contain 2 newer files without path-info.

Move the 2 files:
hpwNewLISP.pub
neoHanoi.lsp
back into the pubdir.

Will replace the zip in the evening.
Sorry for that.
HPW
 

hpwNewLISP

Postby HPW » Wed Dec 10, 2003 2:40 pm

Just released hpwNewLISP 1.02:

Features:
Action: hpwNewLispFileRead - Load files without problems with pipe-character!
(Same function as in hpwUtility)
Last but not least: newlisp.dll Development version 7.3.17
HPW
 

hpwNewLISP

Postby HPW » Thu Dec 11, 2003 1:12 pm

Just released hpwNewLISP 1.03:

Features:

New restart-feature for hpwNewLispCall.
Now it is possible to feed commands into the neobook action-engine and get back into newlisp to generate further action-commands. So it is not necessary to compute a complete action-script at once. You can start generating in neobook and feed more commands on demand.
HPW
 

hpwNewLISP

Postby HPW » Sat Dec 13, 2003 2:33 am

Just released hpwNewLISP 1.04:

Features:

Action: hpwNewLispCall - Support for different callbacks in return-messages with newlisp-restart!
Global var [hpwNewLispRestartCall] contains the current Lisp-call.
In the first nl-restart-call [hpwNewLispRestartCall] is set by the interface and then it can be set from Lisp to call a other function.

Forgot newLSIP 7.400 RC1!


(Edited by HPW at 12:14 pm on Dec. 13, 2003)
HPW
 

hpwNewLISP

Postby HPW » Sat Dec 13, 2003 11:47 am

Just released hpwNewLISP 1.05:

Features:

A customised error-handler in newlisp is now connected with the neobook error-handling via [LastError]

So an error in newlisp pops up the neobook error meassage window.
HPW
 

hpwNewLISP

Postby HPW » Sat Dec 13, 2003 11:55 am

Just upload the plugin, because I forgot to set the plugin-version-number from 1.04 to 1.05.

When you have download it in the last minutes, please reload again and look in the plugin dialog for 1.05.
HPW
 

hpwNewLISP

Postby HPW » Sat Dec 20, 2003 2:00 pm

Just released hpwNewLISP 1.06:

Features:

Action: hpwNewLispCall - 1.Parameter for DLL-Path removed!
Action: hpwSetNewLispDir - Set DLL-Path one time in the pub!
Support for Custom-plugin commands. Definitions in file neoLISP.cmd!
nb_util.lsp renamed to init.lsp which is automaticly loaded by newLISP.
iSEDQuickPDF.lsp with all import functions for iSEDQuickPDF.dll from www.sedtech.com
Final release newLISP.dll 7.400

So now Santa Claus for newLISP fan's can take a rest!

Enjoy.
;-)
HPW
 

hpwNewLISP

Postby Sam Cox » Sat Dec 20, 2003 3:27 pm

Hans-Peter,

You are a magician!  I will be spending the next few days playing with and understanding this wonderful gift -- newLISP itself, of course, your interface, and especially the newest feature which will allow me and others to provide NeoBook-like syntax for this new-found power.

Thank you again, and take a well-deserved break.  Let's see -- according to my clock, it is now about 1:30 AM on Sunday morning in Germany.  Go to bed, my friend.

Merry Christmas!
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

PreviousNext

Return to PlugIn Discussions

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron