home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 67 / IOPROG_67A.ISO / soft / Tools / mwsppv4.exe / CREATEUSERCONTEXT.SCRIPT < prev    next >
Encoding:
Text File  |  2001-11-17  |  1.8 KB  |  58 lines

  1. !!Script
  2. // Copyright ⌐ 2001 - Modelworks Software
  3. // @Created build 561 cm20011116
  4.  
  5. /**
  6. @Tool: createUserContext~create an application context that
  7. has its own data folder. This is done by creating a new
  8. shortcut that will start the IDE using the specified data
  9. folder. Each context will have its own state including 
  10. window list, last project, toolbar states, findParameters,
  11. and so on. This script uses the /inifile command line option.
  12. @EndTool: 
  13. @Summary: createUserContext~create an application context
  14. */
  15.     
  16.     
  17. function DoCommand()
  18. {
  19.     var name = prompt("Enter the name of your user configuration", "");
  20.     if (name && name.length > 0)
  21.     {
  22.         var directory = Application.getFolder("Personal") + "\\" + Application.name + "\\Configurations";
  23.         var userDirectory = newFile(directory + "\\" + name);
  24.         if (!userDirectory.exists)
  25.         {
  26.             if (userDirectory.create())
  27.             {
  28.                 var iniFile = newFile(userDirectory.path + "\\" + name + ".ini");
  29.                 if (iniFile.create())
  30.                 {
  31.                     var editor = openEditor(iniFile.path);
  32.                     if (editor)
  33.                     {
  34.                         editor.append("[Workspace]\nDataPath=" + userDirectory.path + "\n");
  35.                         editor.close(true,false);
  36.                     }
  37.                     
  38.                     var path = directory + "\\" + name + ".lnk";
  39.                     var targetPath = Application.path;
  40.                     var arguments = "/inifile=\"" + iniFile.path + "\"";
  41.                     var workingDirectory = File.getApplicationPath();
  42.                     var description = Application.name + " configuration for " + name;
  43.                     File.createShortcutFile(path, targetPath, arguments, workingDirectory, description);
  44.                     
  45.                     path = Application.getFolder("Desktop") + "\\" + name + ".lnk";
  46.                     File.createShortcutFile(path, targetPath, arguments, workingDirectory, description);
  47.                 }
  48.             }
  49.         }
  50.         else
  51.         {
  52.             alert("A user context already exists with this name.\nYou must choose a different name.");
  53.         }
  54.     }
  55. }
  56.  
  57. !!/Script
  58.