home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / SCRPTEXM.PAK / NETHELP.SPP < prev    next >
Encoding:
Text File  |  1997-05-06  |  2.2 KB  |  85 lines

  1. //--------------------------------------------------------------------------
  2. // Object Scripting
  3. // Copyright (c) 1996, 1997 by Borland International, All Rights Reserved
  4. //
  5. // NETHELP.SPP: Internet Help. Open an URL with Netscape Navigator by
  6. //   selecting from a list of programming pages, FTP sites, and newsgroups.
  7. //
  8. // USE: Run script and select an URL. The data file nethelp.dat contains
  9. //   useful URLs. Add locations to this file using the same format used
  10. //   by existing entries.
  11. //
  12. // FILES: NETHELP.DAT, FILE.SPP
  13. //
  14. // NOTES: All nethelp.* files must reside in the same directory.
  15. //--------------------------------------------------------------------------
  16. print typeid(module());
  17.  
  18. //
  19. // IDE imports.
  20. //
  21. import IDE;
  22. import scriptEngine;
  23.  
  24. //
  25. // Load support module(s).
  26. //
  27. if (!scriptEngine.IsLoaded("file")) scriptEngine.Load("file");
  28.  
  29. URLs;  // Array of URLs.
  30.  
  31. ModuleDir = GetModuleDir(typeid(module()));  // Directory of this script.
  32.  
  33. //
  34. // Get the Netscape Navigator directory from the registry.
  35. //
  36. NetNavDir = GetValueData(0x80000001,
  37.                          "Software\\Netscape\\Netscape Navigator\\Main",
  38.                          "Install Directory");
  39.  
  40. //
  41. // Create a list window.
  42. //
  43. Menu = new ListWindow(200, 50, 200, 350, "Select an URL to open",
  44.                       FALSE, FALSE, NULL);
  45.  
  46. nethelp()
  47. {
  48.   // Load the URL data.
  49.   //
  50.   declare file = new TFlatFile(ModuleDir + "\\nethelp.dat");
  51.   declare lines = file.GetLines();
  52.   file.Close();
  53.  
  54.   //
  55.   // Display a menu. The initialized test stops us at the end of the array.
  56.   // We also ignore any blank lines at the end of the file.
  57.   //
  58.   Menu.Execute();
  59.   URLs = new array[];
  60.   for (declare i = 0; initialized(lines[i]) && lines[i] != ""; i += 2) {
  61.     Menu.Add(lines[i], Menu.Count);
  62.     URLs[i / 2] = lines[i + 1];
  63.   }
  64.   IDE.KeyboardManager.SendKeys("{VK_HOME}", TRUE);
  65. }
  66.  
  67. //
  68. // Handle selections from the menu.
  69. //
  70. on Menu:>Accept()
  71. {
  72.   // Launch Netscape Navigator.
  73.   //
  74.   if (!Spawn(NetNavDir + "\\program\\netscape.exe " + URLs[.CurrentIndex])) {
  75.     IDE.Message("Could not launch Netscape Navigator.", INFORMATION);
  76.   }
  77.  
  78.   // Free up memory.
  79.   //
  80.   delete URLs;
  81.  
  82.   pass();
  83. }
  84.  
  85.