s c h e m a t i c s : c o o k b o o k

/ Cookbook.PLTFileToText

This Web


WebHome 
WebChanges 
TOC (with recipes)
NewRecipe 
WebTopicList 
WebStatistics 

Other Webs


Chicken
Cookbook
Erlang
Know
Main
Plugins
Sandbox
Scm
TWiki  

Schematics


Schematics Home
Sourceforge Page
SchemeWiki.org
Original Cookbook
RSS

Scheme Links


Schemers.org
Scheme FAQ
R5RS
SRFIs
Scheme Cross Reference
PLT Scheme SISC
Scheme48 SCM
MIT Scheme scsh
JScheme Kawa
Chicken Guile
Bigloo Tiny
Gambit LispMe
GaucheChez

Lambda the Ultimate
TWiki.org

Convert any source file to text

Problem

DrScheme saves some files in a binary format that is inconvenient upon occasion. For example, it's difficult to compare these files using 'diff'.

Solution

The following script converts any DrScheme source file to text.

save-as-text.ss

(unless (= (vector-length argv) 2)
  (error 'graphical-to-text "usage: <executable> <input-filename> <output-filename>"))

(define in-filename (vector-ref argv 0))
(define out-filename (vector-ref argv 1))

(define t (new text%))
(send t load-file in-filename)
(define f (new frame% (label "") (width 500) (height 500)))
(define ec (new editor-canvas% (parent f) (editor t)))
(send t save-file out-filename 'text)

To run it, say, under UNIX:

mred -fv save-as-text.ss

Discussion


Comments about this recipe

I've added this to the GettingStartedChapter, for want of anywhere to put it.

-- NoelWelsh - 24 Sep 2004

Contributors

-- JohnClements - 23 Sep 2004

CookbookForm
TopicType: Recipe
ParentTopic: FileRecipes
TopicOrder: 999

 
 
Copyright © 2004 by the contributing authors. All material on the Schematics Cookbook web site is the property of the contributing authors.
The copyright for certain compilations of material taken from this website is held by the SchematicsEditorsGroup - see ContributorAgreement & LGPL.
Other than such compilations, this material can be redistributed and/or modified under the terms of the GNU Lesser General Public License (LGPL), version 2.1, as published by the Free Software Foundation.
Ideas, requests, problems regarding Schematics Cookbook? Send feedback.
/ You are Main.guest