home *** CD-ROM | disk | FTP | other *** search
- //--------------------------------------------------------------------------
- // Object Scripting
- // Copyright (c) 1996, 1997 by Borland International, All Rights Reserved
- //
- // MODLIST.SPP: Module List. Demonstrates how to handle events from
- // other objects to maintain the contents of a list. Implements some
- // of the functionality provided by the Script | Modules dialog.
- //--------------------------------------------------------------------------
- print typeid(module());
-
- //
- // IDE imports.
- //
- import scriptEngine;
- import IDE;
-
- //
- // Unloads this module.
- //
- UnloadOurself()
- {
- scriptEngine.Unload(typeid(module()));
- }
-
- IDE.StartWaitCursor();
-
- declare LoadedModules = scriptEngine.Modules();
-
- ModList = new ListWindow(50, 5, 300, 300, "Module List", TRUE, FALSE,
- LoadedModules);
-
- on ModList:>Delete()
- {
- declare i = 0;
- declare foundSomething = FALSE;
-
- do {
- declare name = ModList.Data[i++];
-
- declare String fName(name);
- fName = fName.Lower();
- if (fName.Index("modlist.sp")) { // Check for .spx or .spp.
- UnloadOurself();
- break;
- }
-
- declare String tmp(name);
- foundSomething = tmp.Length;
-
- if (foundSomething) {
- if (!scriptEngine.Unload(name)) {
- IDE.Message("The unload failed!", INFORMATION);
- print "scriptEngine.Unload failed.";
- }
- }
- } while (foundSomething);
- }
-
- on ModList:>Insert()
- {
- declare name = IDE.FileDialog();
- if (name != "") {
- scriptEngine.Load(name);
- }
- }
-
- //
- // Hook the Accept event in order to do nothing. The default behavior
- // puts the list away.
- //
- on ModList:>Accept()
- {
- declare name = ModList.Data[.CurrentIndex];
- .Delete();
- scriptEngine.Load(name);
- }
-
- declare isInitialized = 0;
- on scriptEngine:>Loaded(arg)
- {
- //
- // The first time this entry is called is when it is being notified
- // of its own load. Since it is already in the module list, don't
- // add it again.
- //
- if (!isInitialized) {
- isInitialized += 1;
- return;
- }
-
- //
- // The first two modules in the chain are always Console Variables
- // followed by the CLIENT object. New modules are added after them
- // so we'll always insert at position 2.
- //
- ModList.Add(arg, 2);
- }
-
- on scriptEngine:>Unloaded(arg)
- {
- declare idx = ModList.FindString(arg);
- ModList.Remove(idx);
- }
-
- on ModList:>Closed()
- {
- UnloadOurself();
- }
-
- IDE.EndWaitCursor();
-
- ModList.Execute();
-
-