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

Messages - hotcore

#1
newLISP in the real world / Re: Error in newLISP-GS
February 24, 2018, 04:01:46 AM
Today I tried to reproduce the error, but I couldn't.

So, perhaps it was just a glitch ...
#2
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
#3
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
#4
Hi rickyboy,



thx for the kind words!  I'll dig in into your comments.



Would you be so kind to publish your amended version?



Best wishes,

   Arie
#5
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
#6
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)
#7
I found the reason why it failed.

Mainargs did return nil in case "newlisp" was not found. Just a stupid error.

Sorry for bothering you.



But very nice that it is possible to load stuff and still create one executable in the go!



Thanks for being patient with me ;-)

   Arie
#8
I forget to mention important info:

   - if run as a script it works

   - if run as an executable it does not work



(BTW I'll have to check for both "newlisp" and "newlisp.exe".)
#9
So, I tried this out.



I have this code:
Quote(define (mainargs)

   (let (osargs (main-args))

      (if (= (lower-case (osargs 0)) "newlisp")

         (1 osargs))))


And the main code:
Quote(load "mainargs.lsp")



(define (showpath myargs)

   (let (pathlist (parse (lower-case (env "PATH")) ";")

            osargs (mainargs))

      (println "===>" osargs (main-args))

      (dolist (line  pathlist)

            (if (> (length osargs) 1)

                  (if (not (nil? (find (lower-case (osargs 1)) line)))

                        (println line))

                  (println line)))))



(println "=====================================================")

(showpath)

(println "=====================================================")

(exit)


Purpose is to display the constituents of the system PATH env var, with or without a search string specified on the commandline.



The code above does NOT work, because the call (mainargs) returns nil.



However, when I comment out the "load" function line and put the mainargs definition at the top of the code, it does work as expected.



I read in the manual that load does not change contexts.



Any help is much appreciated!



Thx,

   Arie
#10
Maybe a dumb answer to self:

IF the first argument is the string "newlisp" it should always be a script.

Thx,

   Arie
#11
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 ;-)
#12
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
#13
Anything else we might add? / Re: Question for neglook
February 18, 2016, 04:10:51 AM
Hi    m i c h a e l



good stuff doesn't come cheap :-(

Did you use it only personally or also in business?

For personal use it is quite expensive!



But indeed thanks for the fantastic video's.

So far the are really the best in teaching programming stuff the easy way afaict.



Keep up the good work!



Arie (a.k.a. hotcore)
#14
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?
#15
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.