From: Ken A. <kan...@bb...> - 2004-03-02 15:02:20
|
You can also make an array with (array class arg ...) or (make-array class size) and access array elements with the Scheme primitives vector-ref and vector-set! They work on any array type. If you're interested in dynamic classpath hacking, see elf/classpath.scm. It provides (url) which will create a URL from a File, String or URL. It also provides addClasspathUrl which will extend the classpath, of the classloader that loaded JScheme, by a url. I use this to make my JScheme environment automatically know about nearby jars. So, for example, if you start JScheme with something like: java -jar lib/jscheme.jar Then the following code will find the lib/ directory, and home directory of the application, and add all the jar's in lib/ to the classpath: (load "elf/classpath.scm") (load "using/run.scm") ;;; lib directory. (define libDir (.getCanonicalFile (.getParentFile (File. ($ "java.class.path"))))) ;;; Application home directory. (define appDir (.getParentFile libDir)) ''' Extend classpath. (for-each addClasspathUrl (files** libDir isJarFile)) At 10:58 PM 3/1/2004 -0500, Timothy John Hickey wrote: >On Monday, March 1, 2004, at 09:59 PM, Enrique Ricoy Belloc wrote: > >>I've started using Jscheme, I want to implement the >>following code, but >>don't know quite how to handle the URL[] definition: >> >> >>URL[] urls = new URL[] { >>new File("C:\\Program Files\\Microsoft SQL Server 2000 >>Driver for >>JDBC\\lib\\msbase.jar").toURL(), >>new File("C:\\Program Files\\Microsoft SQL Server 2000 >>Driver for >>JDBC\\lib\\mssqlserver.jar").toURL(), >>new File("C:\\Program Files\\Microsoft SQL Server 2000 >>Driver for >>JDBC\\lib\\msutil.jar").toURL() >>}; > >I tend to use the (list->array TYPE LIST) procedure >which converts a list into an array of the specified type. >So, to convert a list L of filenames into an array of URLs >you could use the following procedure: > >> (define (filenames->urlarray L) > (list->array java.net.URL.class > (map .toURL > (map java.io.File. L)))) >...... > >which could be applied as follows: > >> (define z (filenames->urlarray (list "lib/jscheme.jar" "lib/applet.jar"))) >..... >> z >#(file:/Users/tim/Research/Software/jscheme/lib/jscheme.jar file:/Users/tim/Research/Software/jscheme/lib/applet.jar) > >Hope this helps, >---Tim--- > >P.S. You can access array elements with (Array.get z n) and (Array.set z n v), e.g. > >> (Array.get z 0) >... >> (Array.set z 1 (Array.get z 0)) >... > > > >>URLClassLoader loader = new URLClassLoader(urls); >>Driver d = (Driver) Class.forName(driverStr, true, >>loader).newInstance(); > >This would rewrite to >(define loader (URLClassLoader. urls)) >(define d (.newInstance (Class.forName driverStr #t loader))) > >> >>--end-- >> >>__________________________________ >>Do you Yahoo!? >>Get better spam protection with Yahoo! Mail. >>http://antispam.yahoo.com/tools >> >> >>------------------------------------------------------- >>SF.Net is sponsored by: Speed Start Your Linux Apps Now. >>Build and deploy apps & Web services for Linux with >>a free DVD software kit from IBM. Click Now! >>http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click >>_______________________________________________ >>Jscheme-user mailing list >>Jsc...@li... >>https://lists.sourceforge.net/lists/listinfo/jscheme-user > > > >------------------------------------------------------- >SF.Net is sponsored by: Speed Start Your Linux Apps Now. >Build and deploy apps & Web services for Linux with >a free DVD software kit from IBM. Click Now! >http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click >_______________________________________________ >Jscheme-user mailing list >Jsc...@li... >https://lists.sourceforge.net/lists/listinfo/jscheme-user |