Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Enabling the REBOL community

From: john:schuhr at: 8-May-2001 22:33

Hi List: This is a first pass at targeting what Joel suggested. I've created a object in "unit.r" called amazingly enough 'unit. It's something of a crude Unit Manager, I suppose. The 'unit has a default library path of %/c/rebol/lib but provides the suggested function for adding new paths to the unit manager. Then whenever you want to use an anonymous object, you just call like so: do %unit.r my-new-object: unit/new %cmptest Where you are trying to create a 'cmptest object using %/c/rebol/lib/cmptest.r The file extension is tacked on automatically to kind of abstract the idea that you're just "including" a reblet somewhere. This way you can focus on "gimme a new 'cmptest object", and not include %cmptest.r so I can get a new object . If there's a another library path that your object file is in: unit/add-lib-path %/c/rebol/powerlib my-powerful-object: unit/new %powerline The code for %unit.r is below.. hope this helps: 8<------------------------------------------------------------------ REBOL [ Title: "Rebol Unit Manager" File: "unit.r" Author: "John Schuhr" Version: 0.1.0 Date: 8-Aug-2001 ] unit: make object! [ lib-paths: [%/c/rebol/lib] add-lib-path: func [new-path [file!]] [ append lib-paths new-path ] new: func [requested-unit [file!] /local new-unit valid-unit] [ valid-unit: make logic! false foreach lib-path lib-paths [ requested-unit-location: join lib-path join "/" join requested-unit ".r" if exists? requested-unit-location [ new-unit: do requested-unit-location valid-unit: true break ] ] if equal? valid-unit false [ make error! "Invalid unit specified" ] new-unit ] ] protect [unit] 8<------------------------------------------------------------------ --John Schuhr At 07:36 PM 5/8/2001 -0500, you wrote: