home *** CD-ROM | disk | FTP | other *** search
- //--------------------------------------------------------------------------
- // Object Scripting
- // Copyright (c) 1996, 1997 by Borland International, All Rights Reserved
- //
- // NETHELP.SPP: Internet Help. Open an URL with Netscape Navigator by
- // selecting from a list of programming pages, FTP sites, and newsgroups.
- //
- // USE: Run script and select an URL. The data file nethelp.dat contains
- // useful URLs. Add locations to this file using the same format used
- // by existing entries.
- //
- // FILES: NETHELP.DAT, FILE.SPP
- //
- // NOTES: All nethelp.* files must reside in the same directory.
- //--------------------------------------------------------------------------
- print typeid(module());
-
- //
- // IDE imports.
- //
- import IDE;
- import scriptEngine;
-
- //
- // Load support module(s).
- //
- if (!scriptEngine.IsLoaded("file")) scriptEngine.Load("file");
-
- URLs; // Array of URLs.
-
- ModuleDir = GetModuleDir(typeid(module())); // Directory of this script.
-
- //
- // Get the Netscape Navigator directory from the registry.
- //
- NetNavDir = GetValueData(0x80000001,
- "Software\\Netscape\\Netscape Navigator\\Main",
- "Install Directory");
-
- //
- // Create a list window.
- //
- Menu = new ListWindow(200, 50, 200, 350, "Select an URL to open",
- FALSE, FALSE, NULL);
-
- nethelp()
- {
- // Load the URL data.
- //
- declare file = new TFlatFile(ModuleDir + "\\nethelp.dat");
- declare lines = file.GetLines();
- file.Close();
-
- //
- // Display a menu. The initialized test stops us at the end of the array.
- // We also ignore any blank lines at the end of the file.
- //
- Menu.Execute();
- URLs = new array[];
- for (declare i = 0; initialized(lines[i]) && lines[i] != ""; i += 2) {
- Menu.Add(lines[i], Menu.Count);
- URLs[i / 2] = lines[i + 1];
- }
- IDE.KeyboardManager.SendKeys("{VK_HOME}", TRUE);
- }
-
- //
- // Handle selections from the menu.
- //
- on Menu:>Accept()
- {
- // Launch Netscape Navigator.
- //
- if (!Spawn(NetNavDir + "\\program\\netscape.exe " + URLs[.CurrentIndex])) {
- IDE.Message("Could not launch Netscape Navigator.", INFORMATION);
- }
-
- // Free up memory.
- //
- delete URLs;
-
- pass();
- }
-
-