(archive 'newLISPer)

November 15, 2006

What's new?

Filed under: newLISP — newlisper @ 23:34

Things are a bit quiet around here at the moment. But I can at least mention a few newLISP-y things, to pass the time until I have something interesting to post…!

  • newLISP on Noodles is a new wiki dedicated to newLISP advocacy. There are quizzes, too, which is cool… :-)
  • visit Fanda’s web site at Intricate Visions for some photography and programming
  • Seth Dillingham created a BBEdit Codeless Language Module for newLISP. You’ll need version 8.5 of BBEdit to use it. He wrote an article about it at the Truer Words site, and you might be interested in his use of recursive back-reference grep patterns to match Lisp parentheses, even if you don’t use BBEdit…
  • If you can understand Russian, you’ll be interested in a new tutorial to newLISP to be found at Dmitry’s EnFeauTec site.
  • There’s lots of good newLISP code at terpri.
  • Both Intricate Visions and Terpri are wikis that use the newLISP wiki code, which you can get from the main newLISP site. One day I hope this blog will move to a newLISP-powered wiki.

I suppose I’d better post a bit of newLISP code. I had to produce some 2007 calendars the other day, and I used the following code to test some of the basic output routines. Here’s a stand-alone version, which needs a PostScript interpreter of some kind to produce output.

(set 'buffer "")
(define (ps str)
	(write-line str buffer))
(define (render)
	  (& 0x7F (sys-info 7)) ; MacOS X...
		  (write-file (string (env "HOME") "noname.ps")
				(string "%!PS-Adobe-3.1" "\n" "%%Creator: newLISP" "\n")
					buffer "showpage" "\r\n")
	  	(exec (string "open "(env "HOME") "/Desktop/noname.ps")))
	  ; other platforms
	  (write-file "noname.ps"
	  	(string "%!PS-Adobe-3.1" "\n" "%%Creator: newLISP" "\n")
	  		buffer "showpage" "\r\n")))
(define (write-string s)
  (ps (format {%f %f moveto} x y))
  (ps (format {(%s) show} s))) ; x and y are unchanged
(define (weekday-format)
  (ps (format {/Eurostile findfont 8 scalefont setfont}))
  (ps (format {0 0 0 setrgbcolor})))
(define (weekend-format)
  (ps (format {/Eurostile findfont 8 scalefont setfont}))
  (ps (format {0 .3 .3 setrgbcolor})))
(define (month-format)
  (ps (format {/Eurostile findfont 12 scalefont setfont}))
  (ps (format {.7 0 0 setrgbcolor})))
(define (next-day)
  (if weekend
  (write-string day-number-text)
  (dec 'y row-height))
(define (new-week)
  (set 'y (- ruler month-day-space))
  (inc 'x column-width))
(define (new-month)
  (and (> x 450)
		(set 'x left-margin)
		(dec 'ruler month-month-space)
		(dec 'y month-month-space))
		(swap y ruler)
		(inc 'x month-width-space)
		(write-string month-name)
		(swap y ruler)
		(ps (format {%f %f moveto} x y))
; start
(set 'x 10
	'y 750
  'ruler y
  'row-height 15
  'left-margin 25
  'column-width 15
  'month-day-space 15
  'month-month-space 160
  'month-width-space 30)
(ps (format
	{0.1 setgray /Eurostile findfont 8 scalefont setfont}))
(ps (format
	{%f %f moveto} x y))
(for (week 0 52)
  (for (day 0 6)
    (set 'date-val
    	(+ (date-value 2007 1 1)
    		 (* 24 60 60 (+ (+ (* 7 week) day)))))
    (set 'day-number (int (date date-val 0 {%d}) 0 10))
    (set 'month-name (date date-val 0 {%B}))
    (set 'day-name (date date-val 0 {%A}))
    (if (starts-with day-name "S") ; weekend, English :-)
      (set 'weekend true)
      (set 'weekend nil))
    (if (= day-number 1) ; start of new month
    (set 'day-number-text
    	(string (date date-val 0 {%d})))


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: