From: Timothy J. H. <tim...@ma...> - 2004-03-02 04:11:25
|
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 |