Qedit for Windows Scripting Language

QSL Scripts Tips

Welcome to the Qedit for Windows Scripting Language support Web pages. The information here provides useful tips to QSL. If you have a version of Qedit for Windows with scripting enabled, you can also access the on-line scripting help by using the Scripting command of the Help menu.

Scripting and Host Commands have been introduced in Qedit for Windows 4.9. If you do not see Script in the menu of your copy of the PC client, you do not have scripting. Contact your site administrator or support@robelle.com for an upgrade.


Links to Helpful QSL Information


Running Scripts

There are a number of ways to run a QSL script:

Executing an Open Script File

The simplest is to just open the file and use Script | Run from the menu. This has the unfortunate side effect of making the script file itself your current file; this is often not what you want when testing a script that does some edit on the current file!

Loading Scripts On The Script Menu

You can add and remove scripts from the Script Menu, making them easy to invoke with another file open as the active file. The manual way to do this is with the Manage Scripts dialog box (see the Script menu).

Scripts that are loaded onto the menu can be organized into groups and assigned shortcut keys. See the Name script attribute in the QSL Reference Manual for more details.

The Manage Scripts dialog box currently only supports browsing and loading scripts from local files, but it is possible to also have host files on the Script menu by using the Loadscript script statement.

Automatically Loaded Scripts

When Qedit starts up, it automatically loads scripts from specially-known locations (but it does not execute them).

Programmatically Loading Scripts

One script can cause another script file to be loaded onto the Script menu dynamically using the Loadscript statement. Once a script is dynamically loaded, it is treated just the same as the scripts which are loaded into other ways. That is, you can invoke it manually from the Script menu or from other scripts (see below).

Calling Scripts From Other Scripts

One script can call a "method" in another script (actually a Sub) by preceding the Sub name with the script name. This only works if the target script is loaded. A script can also refer to the "properties" of another script, but only if they are declared with the special Property keyword in the target script.

Invoking Scripts from Other Scripts

Use the Invoke QSL statement to transfer control to a script. This script must have mainline code to execute. The syntax of the Invoke statement calls for a string containing the file name or a connection name and a filename:
invoke "script name"

Running Scripts From the Command Line

You can direct Qedit to run a script from the command line by including the -r option:

        C:\ROBELLE\QEDIT\qwin32.exe  -r  myscript.qsl

Qedit executes the script specified on the command line after it has finished loading all of the scripts in the two default script directories, but before it opens any text files specified in the command. If the command-line script doesn't call the Exit application method, Qedit remains open after the script terminates.


Other Topics

Interrupting an Executing Script.

Use the Control Panel command on the Script menu and click the Red round stop icon. If a script is not executing, the icon will be grey.

Debugging Scripts.

Use the Dialog and Writelog built-in functions to trace execution and show variable values.

Use Typeof(identifier) to check for spelling errors. Tthe variable that doesn't seem right may come up undefined, which is what happens when you spell the name slightly differently from the real variable -- you just created a new variable, but one without a type because you haven't used it yet!

Turn on the Ruler and Showinvisibles, using the corresponding commands on the View menu or directly from the script, when debugging a script that deals with Tabs and other non-printing characters:

   qedit.userulerbar = true;
   fileA = newfile();
   fileA.showinvisibles = true;

Enable the Script Control Panel either manually or from a QSL script:

   qedit.showscp = true;
For example, try this script:
   repeat for inx from 1 to 10
      writelog(string(inx));
   endrepeat
   qedit.showscp = true;

Side By Side Debugging with the Script Control Panel.

If you have a reasonable size display, try the following:

  1. Start Qedit for Windows.
  2. Make Qedit for Windows so that it is *not* running full-screen.
  3. Invoke the Script Control Panel (Script | Control Panel).
  4. Now use your mouse to move the SCP window off the Qedit for Windows main window frame.
You should now be able to see two windows -- the Qedit for Windows window and the SCP window. If you have enough screen real estate, you should find that debugging scripts via the SCP is a little easier.

Create a Support Library.

If you do much scripting you will find yourself reusing the same support Subs in many scripts. You can put all of these in a single support script and then load it in one of the various ways, thus making the Subs available as utility methods in all other scripts.

And if a script has no On Command blocks and no mainline, it does not even appear on the Script menu, even though it is loaded and accessible from other scripts!