home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / self / contrib.lha / contrib / 491 / loadscript.self next >
Encoding:
Text File  |  1993-07-22  |  1.9 KB  |  55 lines

  1. " Load scripts on a specific path given in lobby searchPath "
  2. " By Michael Richardson <mcr@sandelman.ocunix.on.ca> "
  3. " Modified by Danny Epstein for to be compatible with Self 1.3 beta "
  4. " Version 1 "
  5. " For Self 1.3 beta "
  6. "
  7. * $Id: loadscript.self,v 1.1 1993/05/03 19:17:32 richards Exp richards $
  8. * $Log: loadscript.self,v $
  9. # Revision 1.1  1993/05/03  19:17:32  richards
  10. # Initial revision
  11. #
  12. *
  13. "
  14.  
  15. "Note that _OpenMode searches relative to the directory containing the
  16. snapshot whereas _RunScript searches relative to the SELFDIR
  17. environment variable.  This code assumes that SELFDIR is
  18. ~/self1.3-beta/source and that the snapshot is in ~/self1.3-beta.
  19. Also, _OpenMode assumes the full filname is specified, whereas
  20. _RunScript adds the '.self' suffix itself if it is left out.  This
  21. code also assumes that all Self files use the '.self' suffix."
  22.  
  23. _AddSlotsIfAbsent: ( | _ filein* = () | )
  24. filein _Define: ( |
  25.     ^ searchPath <- list copy.
  26.     ^ loadVerbose <- false.
  27.     ^ load = (
  28.     searchPath do: [ | :aDir. fullname. |
  29.         fullname: aDir, self ,'.self'.
  30.         loadVerbose ifTrue: [ ('Testing for ',fullname) printLine. ].
  31.         (unixFile exists: fullname) ifTrue: [
  32.         loadVerbose ifTrue: [('Loading script: ', fullname) printLine].
  33.         ^ fullname canonicalize _RunScript.
  34.         ].
  35.         ].
  36.     searchPath do: [ | :aDir. fullname. |
  37.         fullname: aDir, self.
  38.         loadVerbose ifTrue: [ ('Testing for ',fullname) printLine. ].
  39.         (unixFile exists: fullname) ifTrue: [
  40.         loadVerbose ifTrue: [('Loading script: ',fullname) printLine].
  41.         ^ fullname canonicalize _RunScript.
  42.         ].
  43.     ].
  44.     ('\'', self, '\' not found in searchPath.') printLine.
  45.     'File not loaded.' printLine.
  46.     nil
  47.     ).
  48. | )
  49.  
  50. searchPath addLast: ''           "~/self/"            "temporary changes"
  51. searchPath addLast: 'mcrhack/'    "~/self/mcrhack/"    "local hacks"
  52. searchPath addLast: 'changes/'   "~/self/changes/"    "changes"
  53.  
  54.