[gambit-list] iOS Gambit REPL question

Marc Feeley feeley at iro.umontreal.ca
Sat Apr 28 23:01:45 EDT 2012


On 2012-04-28, at 3:49 AM, Edward P Luwish wrote:

> How can one retrieve a saved file and edit it?

Scripts can be created with the script editor, which stores these scripts in an internal database.  A script can be saved to the Documents folder by clicking the "save" button.  However, Gambit REPL does not provide "out of the box" an "open" functionality which would allow copying a script from the Documents folder to the internal script database.

The good news is that this functionality can be added easily.  For example, add the following code to the "main" script, so that these definitions are available the next time you launch Gambit REPL:

(define (open name)
 (script#add-script name (call-with-input-file name (lambda (p) (read-line p #f))))
 (gr#set-edit-view)
 (edit))

(define (ls)
 (for-each pp (directory-files)))

Now you can evaluate (ls) to get a list of the files in the Documents folder.  To open a file "foobar.scm" in the script editor, simply evaluate (open "foobar.scm") .

A more user-friendly interface to this functionality would be nice, but I have no plans for that right now.

Marc




More information about the Gambit-list mailing list