Here are some brief examples of scripts using jEditLauncher. The first two will run under Windows Script Host, which is either installed or available for download for 32-bit Windows operating systems. The next example is written in Perl and requires the Win32::OLE package. The last is written in Python and requires the win32gui and win32com.client extensions.
If Windows Script Host is installed, you can run the first two scripts by typing the name of the file containing the script at a command prompt. In jEdit's Console plugin, you can type cmd /c script_path or wscript script_path.
' Example VBScript using jEditLauncher interface dim launcher set launcher = CreateObject("JEdit.JEditLauncher") a = Array("I:\Source Code Files\shellext\jeditshell\*.h", _ "I:\Source Code Files\shellext\jeditshell\*.cpp") MsgBox "The server authorization code is " + _ FormatNumber(launcher.ServerKey, 0, 0, 0, 0) + ".", _ vbOKOnly + vbInformation, "jEditLauncher" launcher.openFiles(a) myScript = "jEdit.newFile(view); textArea.setSelectedText(" _ & CHR(34) _ & "Welcome to jEditLauncher." _ & CHR(34) & ");" launcher.evalScript(myScript) |
/* Example JScript using jEditLauncher interface * Note: in contrast to VBScript, JScript does not * directly support message boxes outside a browser window */ var launcher = WScript.createObject("JEdit.JEditLauncher"); var a = new Array("I:\\weather.html", "I:\\test.txt"); b = "I:\\*.pl"; launcher.openFiles(a); launcher.openFile(b); c = "G:\\Program Files\\jEdit\\macros\\Misc" + "\\Properties\\System_properties.bsh"; launcher.runScript(c); |
# Example Perl script using jEditLauncher interface use Win32::OLE; $launcher = Win32::OLE->new('JEdit.JEditLauncher') || die "JEditLauncher: not found !\n"; @files = (); foreach $entry (@ARGV) { @new = glob($entry); push(@files,@new); } $launcher->openFiles(\@files); my($script) = "Macros.message(view, \"I found " .(scalar @files)." files.\");"; $launcher->evalScript($script); |
# Example Python script using jEditLauncher interface import win32gui import win32com.client o = win32com.client.Dispatch("JEdit.JEditLauncher") port = o.ServerPort if port == 0: port = "inactive. We will now launch jEdit" win32gui.MessageBox(0, "The server port is %s." % port, "jEditLauncher", 0) path = "C:\\WINNT\\Profiles\\Administrator\\Desktop\\" o.RunDiff(path + "Search.bsh", path + "Search2.bsh") |