Pocket Scheme - sample code directory

Sample code for version 1.3

The following samples work on the most recent release of Pocket Scheme. I will amend these as I find the time. (Every 1.2 sample should work on 1.3, too. I just haven't had time to test them all.)

slibinit.scm
Definitions to use SLIB with Pocket Scheme.
w32api.scm
Imports for a subset of the Win32 API. Extend this as necessary, or prune it for faster loading. To extend this, you will need the function prototypes and constant definitions from the SDK. (While function prototypes appear in the MSDN online SDK documentation, manifest constant definitions only appear in the SDK header files.)

I change the contents of this file from time to time. If one of the following samples fails, complaining of a reference to unbound variable, please refresh your copy of this file.

w32ppc.scm
More imports for PPC-only APIs.
w32message.scm
Definitions for Win32 window messages. Extend this as necessary, or prune it for faster loading.
timeclnt.scm
A simple network time client, per RFC 868 (the old non-compensated Time/TCP protocol). Demonstrates a TCP client and simple numeric network I/O.
sdkgeneric.smd
The CE 2.0 SDK generic.cpp application, as rendered in Pocket Scheme. This demonstrates the use of the three preceding interface libraries to create a GUI application. It probably won't make any sense to you unless you're already comfortable writing Windows applications in C. Uses the w32:host-topmost procedure, new in 1.3.
exn.scm
Contains a library of functions for manipulating exceptions. Use this if you use the with-handlers facility.
letcc.scm
Defines the letcc construct used in many examples of The Seasoned Schemer.

Sample code for version 1.2

The following samples work on Pocket Scheme 1.2, released in 2005.

slibinit.scm
Definitions to use SLIB with Pocket Scheme.
w32api.scm
Imports for a subset of the Win32 API. Extend this as necessary, or prune it for faster loading. To extend this, you will need the function prototypes and constant definitions from the SDK. (While function prototypes appear in the MSDN online SDK documentation, manifest constant definitions only appear in the SDK header files.)

I change the contents of this file from time to time. If one of the following samples fails, complaining of a reference to unbound variable, please refresh your copy of this file.

w32ppc.scm
More imports for PPC-only APIs.
w32message.scm
Definitions for Win32 window messages. Extend this as necessary, or prune it for faster loading.
scmsrvtst.scm
Implements a simple TCP server. It offers a fair example of soft (user-defined) ports and exception handling. You will need a NIC of some sort in your Pocket PC (a Wi-Fi adapter works, as does a BlueTooth PAN driver) in order to access this server. (While an ActiveSync connection to a host PC establishes a PPP link between the two devices, there is no route back from the host to the device.)
timeclnt.scm
A simple network time client, per RFC 868 (the old non-compensated Time/TCP protocol). Demonstrates a TCP client and simple numeric network I/O.
sdkgeneric.smd
The CE 2.0 SDK generic.cpp application, as rendered in Pocket Scheme. This demonstrates the use of the three preceding interface libraries to create a GUI application. It probably won't make any sense to you unless you're already comfortable writing Windows applications in C.
cm17a.scm
An interface library for the X10 "FireCracker" (CM17A) home automation controller. Intended for use in a script, e.g. my catbedon.smd:

(load "cm17a.scm")
(display "Turning on the cat's bed-warmer.")
(newline)
(firecracker-on "A1")

At the top of cm17a.scm I define two numeric values, time-warmup and time-pulse, which specify delays in milliseconds for warming up and holding a pulse in the signal to the CM17A transmitter. The greater the value of time-pulse, the longer the CM17A will spend transmitting each bit of the signal, making its RF transmission more robust. Reducing this value to 1 will greatly speed operation, but will reduce the radius of effective operation to point-blank range (less than 7 meters).

Also, please remember that the synch cable for CE devices is a null-modem cable, wired as DCE instead of DTE. You will need a null-modem adapter, as opposed to a simple gender changer, if you plan to plug the CM17A into the DB9F at the distal end of the cable.

grep.smd
A simple script that finds lines in text files matching a given pattern.
subst.smd
Another simple script that performs text substitution in files. Helps compensate for the lack of a Replace function in the Pocket Scheme Editor.
exn.scm
Contains a library of functions for manipulating exceptions. Use this if you use the with-handlers facility.
letcc.scm
Defines the letcc construct used in many examples of The Seasoned Schemer.

Sample code for version 1.1

The following samples work only on the previous five-year-old release of Pocket Scheme, version 1.1; I haven't yet finished porting them to 1.2. They will not work on the current release. I present them here only as partial examples.

Most of these samples were written for Windows CE. Many of them will run on Windows NT or 2000 as well, either as-is or after setting the variable *windows-ce* to #f. To run them on 95, 98, or ME, you may need to modify foreign procedure and structure imports to reference narrow-character instead of wide-character entry points.

ftp.scm
Implements a simple FTP client, capable of uploading, downloading, or listing the contents directories on servers that accept anonymous connections. (While it would be trivial to make this use authenticated connections, I'm a little shy about pushing passwords around in plaintext.)
plot.scm
A simple facility for graphically plotting data.

Usage: (SHOW-PLOT l), where l is a list of the following plotting commands:

Usage example: (SHOW-PLOT '((ORIGIN CENTER) (SHAPE CIRCLE 3) (5 5) (5 -5) (-5 5) (-5 -5)))

As a code sample, this library demonstrates proper application behavior in the presence of the Palm-sized PC input panel. It could use some additional work for the Pocket PC.

clipdemo.scm
The w32.dll functions clipboard->string and string->clipboard, rewritten to demonstrate use of the Pocket Scheme FFI. Windows NT/2000/XP only.
cerun.scm
A script that I threw together to launch programs on a CE device from the desktop. Windows NT/2000/XP only.

Other destinations

Pocket Scheme
Back to the Pocket Scheme page.
Site Map
Find your way around this site

Last modified: Sun Apr 02 15:35:37 Pacific Standard Time 2006

Ben Goetter (contact information)

Copyright 2005, Ben Goetter. All rights reserved.