-
Notifications
You must be signed in to change notification settings - Fork 87
main.scm
Chris Petersen edited this page Aug 6, 2013
·
4 revisions
The main.scm
file contains the application source code.
Code can be either straight-forward Scheme for console-based
applications, or event loop based code for graphical applications.
Event loop based applications need a main
procedure
call. The arguments to the call are handlers for
initialization, event handling, termination, suspend and resume.
For example, the following program creates a GUI with a
red square box in the initialization call, and renders
it in the event loop call:
(define gui #f)
(main
;; initialization
 (lambda (w h)
(make-window 320 480)
(glgui-orientation-set! GUI_PORTRAIT)
(set! gui (make-glgui))
(let* ((w (glgui-width-get))
(h (glgui-height-get))
(dim (min (/ w 2) (/ h 2))))
(glgui-box gui (/ (- w dim) 2) (/ (- h dim) 2) dim dim Red))
)
;; events
(lambda (t x y)
(if (= t EVENT_KEYPRESS) (begin
(if (= x EVENT_KEYESCAPE) (terminate))))
(glgui-event gui t x y))
;; termination
(lambda () #t)
;; suspend
(lambda () (glgui-suspend))
;; resume
(lambda () (glgui-resume))
)
Console programs doesn't need an event loop. The simplest possible application in console mode is:
(display "HelloWorld")
which just displays the text and exits. A more useful console program that provides access to the Gambit interpreter is:
(display "DemoConsole\n")
(let loop ()
(with-exception-catcher (lambda (e)
(for-each display
(list (exception->string e) "\n")) #f)
(lambda () (##repl-debug)))
(loop))
-
- accelerometer
- alist
- audio
- audioaux
- base64
- btle-scan
- camera
- cdb
- cgi
- config
- csv
- curl
- digest
- dmtx
- download
- eventloop
- fcgi
- fft
- generalized-arrays
- gps
- graph
- gyro
- hidapi
- hpdf
- html
- httpsclient
- hybridapp
- json
- lmdb
- ln_core
- ln_glcore
- ln_glgui
- ln_store
- localization
- localization_gui
- localnotification
- magnetometer
- mdns
- mqtt
- mqtt-store
- multitouch
- oauth
- orientation
- p256ecdsa
- png
- portaudio
- pregexp
- pressure
- prime
- pushnotification
- redcap
- rsa
- rtaudio
- rupi
- rotation
- sanestring
- scheduler
- serial
- sets
- settings
- simplexnoise
- sqlite
- ssax
- syntax-case
- timestamp
- ttf
- uiform
- url
- uuid
- vibrate
- videoplayer
- watchdog
- website
- xml
- zip