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

#1
newLISP newS /
June 27, 2007, 01:11:23 AM
in newlisp-edit.lsp:


(constant 'TEMP_DIR (if (= ostype Win32) "C:\temp" "/tmp"))

Win32 must be in quotes.

i already mentioned this in previous topic
#2
newLISP newS /
June 26, 2007, 06:22:31 AM
thanks Lutz!

i found this place in the beginning of newlisp-edit.lsp, i think there also must be



(if (= ostype "Win32") "C:\temp" "/tmp")


("Win32" instead of Win32)

i fixed that, created "c:\temp" directory and now it works.
#3
newLISP newS /
June 26, 2007, 02:03:18 AM
the same problem with newlisp-edit.lsp



message-dialog: cannot be applied to MAIN:TheEditor



all other demos runs fine, including new 2D-graphics stuff

(this looks great. congrats Lutz!)
#4
newLISP newS /
June 24, 2007, 01:42:45 PM
i have updated all this files to the latest version before posting here

just checked this again

i have newlisp 9.1.1 installed. maybe this is the reason
#5
newLISP newS /
June 24, 2007, 11:53:22 AM
Hi, Lutz!

maybe i missed something but newlisp-edit.lsp doesn't work on my system.

it shows an error:



  message-dialog:

  cannot be applied to MAIN:TheEditor



and then it exits

all other demos works fine
#6
hi

i am trying to work with sockets for the first time.

i need a function that reads exactly n bytes from the socket (and blocks until they are available)

how can i do this?
#7
newLISP and the O.S. /
May 23, 2007, 02:57:13 PM
you're right, i put x after comma just in case :)



good idea with currying, it may be useful

i used for different tasks similar recursive walk function (much like in python os.walk) but without curry.
#8
newLISP and the O.S. /
May 22, 2007, 12:17:48 PM
i totally agree ;D
#9
newLISP and the O.S. /
May 22, 2007, 10:44:10 AM
I put "x" and "full" in define statement to make them local to this function.



http://newlisp.org/CodePatterns.html#locals">//http://newlisp.org/CodePatterns.html#locals



Also in this case they don't pollute global namespace. In recursive functions non-local variables may cause big problems, as they are shared between all running functions.
#10
Anything else we might add? /
May 21, 2007, 11:04:28 AM

(set 'b1 (list cmin cmin cmin))
#11
newLISP and the O.S. /
May 20, 2007, 11:13:35 PM
this recursive version is better

i forgot about it :)



(define (remove-all root, x full)
    (dolist (x (directory root))
        (set 'full (append root "/" x))
        (if (directory? full)
            (if (and (!= x "..") (!= x "."))
                (begin
                    (remove-all full)
                    (remove-dir full)))
            (delete-file full))))


example:


(remove-all "c:\temp")
(remove-dir "c:\temp")
#12
newLISP and the O.S. /
May 20, 2007, 02:14:45 PM
Hi, SHX!

try this function:



(define (remove-all dir)
    (set 'fnames (list dir))
    (set 'dirs '())

    (while (not (empty? fnames))
        (set 'fname (pop fnames))
        (if (directory? fname)
            (begin
                (dolist (x (directory fname))
                    (if (and (!= x ".") (!= x ".."))
                        (push (append fname "/" x) fnames)))
                (if (!= fname dir) (push fname dirs)))
            (delete-file fname)))

    (dolist (x dirs) (remove-dir x)))


it removes all files and subdirs in directory.

i tested it on windows xp only



edit: to remove root folder as well replace

  (if (!= fname dir) (push fname dirs))

with just

  (push fname dirs)
#13
Recently i wrote a few  opengl demos in newlisp just for fun, in which i used simple TGA texture loading function. The problem is that in tga image data colors go in BGR or BGRA order and i use GL_BGR_EXT and GL_BGRA_EXT extensions. What i want is to change color order to standard RGB and RGBA in a fastest way and use GL_RGB and GL_RGBA. I wrote two functions for this purpose:



;; bgra -> rgba
(define (swaprb32 data)
    (join (map (lambda (x) (select x 2 1 0 3)) (explode data 4)) ""))

;; bgr -> rgb
(define (swaprb24 data)
    (join (map reverse (explode data 3)) ""))

;; testing
(print "test-rgba: ")
(set 'testdata (dup "bgra" (* 512 512)))  ; data from file
(set 'testres  (dup "rgba" (* 512 512)))  ; what i want to get
(print (time (set 'res (swaprb32 testdata))) " ")
(println (= res testres))

(print "test-rgb: ")
(set 'testdata (dup "bgr" (* 512 512)))
(set 'testres  (dup "rgb" (* 512 512)))
(print (time (set 'res (swaprb24 testdata))) " ")
(println (= res testres))


but maybe there is a better way to do this thing?

any suggestions?

results i get for 512x512 image:

 test-rgba: 781 true

 test-rgb: 609 true
#14
newLISP and the O.S. /
December 26, 2006, 03:00:48 AM
Thanx Lutz!

Now all works fine.
#15
newLISP and the O.S. /
December 24, 2006, 03:05:43 PM
perhaps something is wrong with my system..

newlisp 9.0 - same results.

i have Intel Core 2 Duo and NTFS-formatted disk