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 - hotcore

#1
newLISP in the real world / Error in newLISP-GS
February 23, 2018, 08:55:42 AM
In newLISP-GS I have 2 tabs:

1. untitled.lsp (not used)

2. fip.lsp (used)



When I needed to temporarily cut a part from src in tab 2, I clicked on tab 1 to paste it there.



When clicking on tab 1 I get:



select-text-tab-4BA94169-1423-4038-BDBF-F6363D38791A 105 0:

Could not invoke method select-text with-tab-4BA94169-1423-4038-BDBF-F6363D38791A
#2
I found an earlier report about this, but it does not seem to be solved yet.

When reverting back to Java 8 everything is just fine.



Can I be of any help to find the culprit?



Kind regards,

   Arie
#3
newLISP in the real world / Created an include script
February 29, 2016, 07:38:01 AM
I discovered the hard way that, when creating a Windows executable, only the 1 script mentioned will be part of that executable, so (load "script.lsp") will only be satisfied at run time of the exe, and not at generate time.



Because I wanted to create executables having (load ...) in them, I created a script which

     1) copies each input line of a given input script to an output file except when the first thing on the line is "(load ". In that case the contents of the lsp file in the "(load " will be written to the output

     2) start NLINC with only the script name (no path and no extension)

     3) the work should be done in the source directory (in my case all sources in one dir) see Windows script



Updates per 20160301:

- some error handling added

- avoiding recursive includes now



The way it works I now can use (load ...) in my scripts and use them as a normal script or as an (expanded) script turned into an executable.



Any comments and remarks are welcome



Regretting now to have been side tracted from newLISP. It is a pleasure writing code in!



Thx,

   Arie

 

Code of newLISP script:
; ################################################################################
; # NLINC
; #
; # Purpose:
; #    - read a newLISP script xxx.lsp
; #    - if there are LOAD functions (on the utter left of a line)
; #      these will be replaced by the loaded MEMBER itself (INCLUDED)
; #    - output will be written to xxx-i.lsp
; ################################################################################

(define (mainargs , osargs srch)
(setq osargs (main-args))
(setq srch   (lower-case (osargs 0)))
(if (or (= srch "newlisp") (= srch "newlisp.exe"))
(2 osargs)
(1 osargs)))

(define (check-include line , incmem)
(setq line (lower-case (trim line)))
(if (!= (0 6 line) "(load ")
(setq imcmem nil)
(begin
(setq line (6 line))
(setq incmem ((parse line {"}) 1))))
incmem)

(define (write-incmem incmem out , memfile)
(setq memfile (open incmem "read"))
(write-line out (append "; NLINC: member " incmem " included here") )
(while (read-line memfile)
(write-line out (current-line)))
(close memfile)
)

(define (pass , in out incmem extra-pass)
(setq in        (open wf1 "read"))
(setq out       (open wf2 "write"))
(setq extra-pass nil)
(println "NLINC: entering pass " (inc passnum) " ...")
(while (read-line in)
(setq line (current-line))
(setq incmem (check-include line))
(cond ((nil? incmem) (write-line out line))
((find incmem inclist) (write-line out (append "; " line)))
(true
(push incmem inclist)
(write-incmem incmem out)
(setq extra-pass true))))
(close in)
(close out)
extra-pass)

(define (nlinc , extra-pass scriptname script wf1 wf2 tmp)
(setq extra-pass true)
(setq scriptname ((mainargs) 0))
(setq script     (append scriptname ".lsp"))
(setq wf1        (append scriptname "-i1.lsp"))
(setq wf2        (append scriptname "-i2.lsp"))
(setq scriptout  (append scriptname "-i.lsp"))
(setq swapped    nil)
(setq inclist    '())
(setq passnum    0)
(setq tmp        "")
(if (not (file? script))
(begin
(println "NLINC: you may only specify the name part of the script")
(println "       without path and extension!")
(exit 999)))
(println {NLINC: processing started for script "} script {"})
(copy-file script wf1)
; Loop over the script and include
; If any script included, repeat until nothing included
; Avoid duplicate includes
(while extra-pass
(setq extra-pass (pass wf1 wf2))
(setq tmp wf2)
(setq wf2 wf1)
(setq wf1 tmp)
(if swapped
(setq swapped nil)
(setq swapped true)))
(delete-file scriptout)
(if swapped
(begin
(rename-file wf1 scriptout)
  (delete-file wf2))
(begin
(rename-file wf1 scriptout)
(delete-file wf2))))

(nlinc)
(exit)


Windows script to build an executable and copy it to a directory in PATH env var:
e:
cd srcnewlisp
newlisp nlinc.lsp %1
newlisp -x %1-i.lsp %1.exe
move /y %1.exe e:scripts
del %1-i.lsp
#4
Maybe somebody is interested in the code below.

The main function is to show the contents of the Windows path, line by line. You may specify a search string on the comaand line to filter the output.



More important is the separate code for a function which takes care of the difference in command line arguments between running as a script and running as an executable.



Code to be "included" (loaded) by the main porogram:
(define (mainargs)
(letn (osargs (main-args)
(srch (lower-case (osargs 0))))
(if (or (= srch "newlisp") (= srch "newlisp.exe"))
(1 osargs)
osargs)))


Main program which loads the above code:
(load "mainargs.lsp")

(define (showpath myargs)
(let (pathlist (parse (lower-case (env "PATH")) ";")
osargs (mainargs))
(dolist (line  pathlist)
(if (> (length osargs) 1)
(if (not (nil? (find (lower-case (osargs 1)) line)))
(println line))
(println line)))))

(println "=====================================================")
(showpath)
(println "=====================================================")
(exit)
#5
Warning: no trolling - no flame ware!!!!



These days I compared the building of an executable from a (very small) comparable Python and a newLISP script.



Python:

    - first install pyinstaller (which is quite big)

    - run pyinstaller for the script (create just an executable)

    - it takes quite some time and lots of warnings

    - executable size is .... greater than 4.5 megabytes



newLISP:

    - create executable easy using a commandline switch

    - executable produced almost instantly

    - executable size is ..... 309 kilobytes



So kudos again ;-)
#6
Hi,



I discovered that (logically) the first os commandline parameter "newlisp" is missing from (main-args) when run from an executable.



Is it possible to detect if a script is run as a script or as an executable?

That way it would be easier to test properly for both cases!



TIA,

   Arie
#7
Anything else we might add? / Question for neglook
February 14, 2016, 04:49:29 AM
I am wondering which tools neglook uses to create these wonderful video's!

Would be very interested to know and use them.



Is it Powerpoint?
#8
Since long I am a fan of languages that aren't bloatware.

By that I mean they have a (very) small footprint on disk and often installing isn't even necessary.



In my quest I encountered a few:

   - newLISP (in the past I dabbled a bit in it - no serious work)

   - Rebol (used that a lot)

   - Red ( //red-lang.org ) a very promising descendant of Rebol

   - 8th ( //8th-dev.com ) a descendant of Forth (currently studying 8th)



A few days ago I was in need of a small utility and wanted to build it fast.



I chose newLISP and I was amazed by how easy I could pick up all necessary bits and pieces

from the docs and in almost no time I had my utility running.



I have to say that I used other Lisp dialects like Common Lisp, Clojure and Scheme. All these were far more difficult (at least for me) to build a featureful program in a short time.



So I wish to send kudos to the developer!  I hope this language as well as the others mentioned above will prosper.
#9
Anything else we might add? / Request new forum sections
February 06, 2016, 08:20:14 AM
Hi,



wouldn't it be nice to add 2 sections:

   - General discussion

   - Problems

to the forum.



It seems there is no right section for this currently.



Best,

   Arie
#10
Whither newLISP? / The future of newLISP
May 23, 2014, 11:57:14 AM
Hi,

just curious!

I am wondering if Lutz is the only developer of newLISP.

Are there any plans for the near and farther development future of newLISP.

Thx,

   Arie
#11
Hi,

i get an error (from newLISP GUI server) when i try to start newLISP.
QuoteRun-shell:

Could not start C:Program Filesnewlisp/newlisp.exe -C -w "C:UsersArie"

What is wrong??

Thx, Arie
#12
Hi,



when I search for hyphenated words in the forum (e.g. text-field) no results will be shown. That's a pity!



/Arie
#13
Hi,



having written my first little newlisp app after lurking now and then on this forum, I have a small problem.

In the code below, when I do NOT enter anything in the input field and push the f->c button, the buttonhandler seems not to work.

The println is not executed! What am I doing wrong?

Thx, Arie


(load (append (env "NEWLISPDIR") "/guiserver.lsp"))

(define (f2c x)
(set 'y (float x nil))
(println "y=" y ";")
(cond
(y (string (div (sub y 32.0) 1.8)))
(true "enter a number")
)
)

(define (c2f x)
(set 'y (float x nil))
(cond
(y (string (add (mul y 1.8) 32.0)))
(true "enter a number")
)
)

(gs:init)

(gs:frame 'Convert 300 300 270 120 "Convert Fahrenheit & Celsius")
(gs:set-resizable 'Convert nil)
(gs:set-border-layout 'Convert)

(gs:panel 'Input)
(gs:set-flow-layout 'Input "left")
(gs:label 'Inlab "Input value:" "left" 44)
(gs:text-field 'Inval 'text-handler 20)
(gs:add-to 'Input 'Inlab 'Inval)

(gs:panel 'Output)
(gs:set-flow-layout 'Output "left")
(gs:label 'Outlab "Output value:" "left" 35)
(gs:label 'Outval "")
(gs:add-to 'Output 'Outlab 'Outval)

(gs:panel 'Button)
(gs:set-grid-layout 'Button 1 2)
(gs:button 'f2c 'button-handler "Convert F -> C")
(gs:button 'c2f 'button-handler "Convert C -> F")
(gs:add-to 'Button 'f2c 'c2f)

(gs:add-to 'Convert 'Input "north" 'Output "center" 'Button "south")

(gs:set-visible 'Convert true)

(define (text-handler id value) nil)

(define (button-handler id value)
(cond
((= id "MAIN:f2c")
(gs:set-text 'Outval (f2c (gs:get-text 'Inval))))
((= id "MAIN:c2f")
(gs:set-text 'Outval (c2f (gs:get-text 'Inval))))
(true
(gs:set-text 'Outval "invalid id detected"))
)
)

(gs:listen)