Archive for April 4, 2004

Sunday, April 4, 2004 [Tweets] [Favorites]

Modal Web Server

Chris Double implemented a simple continuation-based Web framework in Scheme. Here’s an example:

‘show-message’ is a function that displays an HTML page with a message and an ‘Ok’ anchor. The ‘Ok’ anchor goes to an URL as described above:

(define (show-message msg)
  (show
   (lambda (url)
     (sxml->html-string
      `(html
        (head (title ,msg))
        (body
         (p ,msg)
         (p (a (@ (href ,url)) "Ok")))))))

We can use this by registering with the server a function that calls it a couple of times:

(register-function
 (lambda ()
   (show-message "Hello")
   (show-message "World")))

Accessing the registered function displays the first ‘Hello’ page. Clicking ‘Ok’ will then resume the function and display the second ‘World’ page. Clicking ‘Ok’ on that page exits the function.

Property List Tools 1.0

Late Night Software’s Property List Tools can convert property list files into AppleScript records and also save the records back to disk as property list files.

read property list file "HD:Users:mjt:Library:Preferences:com.c-command.DropDMG.plist"
{
    |NSWindow Frame MJTRegistrationWindow|:"616 395 477 436 0 0 1280 1002 ", 
    |NSWindow Frame AgreementsWindow|:"-313 476 265 308 -1280 0 1280 1024 ", 
    |DropDMGDestination|:"~/Desktop", 
    |NSFontPanelLastUsedPane|:0, 
    |NSFontPanelPreviewHeight|:0.0, 
    |DropDMGDiskImageOptions|:{
        |InternetEnabled|:false, 
        |UseEncryption|:false, 
        |Format|:0, 
        |WrapPackages|:true, 
        |DeleteAfterCreating|:true, 
        |Encoding|:2, 
        |DeleteAfterConverting|:false, 
        |Prompt|:false, 
        |AutoOpen|:true, 
        |SegmentSize|:4300, 
        |UseSegments|:false
    },
    …
}