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

[REBOL] Library loader

From: andrew::martin::colenso::school::nz at: 24-Dec-2003 22:45

Here's my Library loader script: use [Patches Files Provided Do_Script Defer_Script Script Header Requires Provides] [ do Patches: %Patches.r Files: exclude read %./ reduce [Rebol/script/header/File Patches] Provided: make block! 100 Do_Script: [ do Script if all [ not none? Provides Provides: get Provides any [ word? Provides block? Provides ] ] [ insert tail Provided Provides ] true ] foreach File Files [ Defer_Script: [ insert/only tail Files Script ] Script: any [ if block? File [ File ] if all [ file? File found? find/last File %.r ] [ load/header File ] ] if Script [ Header: first Script Requires: in Header 'Requires Provides: in Header 'Provides any [ if none? Requires Do_Script if word? Requires: get Requires [ either found? find Provided Requires Do_Script Defer_Script ] if block? Requires [ either empty? exclude Requires Provided Do_Script Defer_Script ] ] ] ] ] It examines each script's header for the 'Requires and 'Provides fields, like (from my ML.r %script): Requires: [Build-Tag Push Pop] Provides: [ML] It doesn't attempt to do any versioning or downloading, just 'load-s and 'do-es scripts so that scripts that require words defined are 'do-ne after scripts that provide values for those words. For the above example, the files that provide 'Build-Tag, 'Push & 'Pop are 'do-ne before the file containing a value for 'ML. One problem the above script has, it that if a script requires a value for a word that no other script provides, the above function never returns. I haven't figured out a solution for this. Can anyone think of one? Andrew J Martin Attendance Officer Speaking in tongues and performing miracles. Colenso High School Arnold Street, Napier. Tel: 64-6-8310180 ext 826 Fax: 64-6-8336759 DISCLAIMER: Colenso High School and its Board of Trustees is not responsible (or legally liable) for materials distributed to or acquired from user e-mail accounts. You can report any misuse of an e-mail account to our ICT Manager and the complaint will be investigated. (Misuse can come in many forms, but can be viewed as any material sent/received that indicate or suggest pornography, unethical or illegal solicitation, racism, sexism, inappropriate language and/or other issues described in our Acceptable Use Policy.) All outgoing messages are certified virus-free by McAfee GroupShield Exchange Phone: +64 6 843 5095 or Fax: +64 6 833 6759 or E-mail: [postmaster--colenso--school--nz]