Scripting LiteStep 0.24.6/LiteStep 0.24.7 with mzScript (pre) 1.0 and TextEdit 2.4.14 (updated)
We have been putting mzScript through some severe punishment within LDE for some time here. The scripting is actually fairly straightforward within mzScript and it is extremely flexible. Virtually anything you might want to do within LiteStep can be achieved with mzScript and, in certain cases you can also use it with something like TextEdit 2.x to write out changes to files, not just step.rc.
To start with you can start to define custom bang commands using structures like*Script bang !mybang
*Script exec !about
*Script ~bangEach line starts with *Script so that mzScript knows to use it.
Taking this line by line, the *Script bang !mybang line defines the creation of a new bang command called mybang. Every declaration has to have a termination as shown in the last line by *Script ~bang.
Everything between the *Script bang !mybang and *Script ~bang is then performed when you call !mybang from LiteStep. At the moment, if you type !mybang into an LSXCommand window, or use it from a shortcut, you will get the same result as if you typed in !About. Note that you can use either ! or | to define bang commands - mzScript will recognise |About and !About as the same thing, but it's recommended to use ! for readability.
The *Script exec !about entry in the script is responsible for this - the 'exec' is there to tell mzScript that this is a command within the !mybang script. exec lines have to lie within a script definition (i.e. between the bang and ~bang lines)
You can 'exec' applications or other !bang commands - even other mzScript scripts, with no problems at all (you can call !mybang itself and loop the system for example, but it's not a good idea).
Its capabilities go further, however. mzScript supports variables, but don't think for one minute that they are the same as the E-Vars that LiteStep uses. They are completely independent and very flexible.
mzScript will allow you to set variables for use using*Script exec !VarSet myvariable "mydefinition"(quotation marks are not neccessary, but usually advisable)
You can delete an mzScript variable using*Script exec !VarRemove myvariableTo use a variable, several functions are available to you
*Script exec !ifExist myvariable [!about][!recycle]In this case, if the variable myvariable exists, the script will bring up an about box. If it doesn't exist, LiteStep will recycle. It's a simple, but pointless example.
You can also go further by handling variables more directly. To do this, you need to enclose the variable name within a marker block that mzScript uses to differentiate variables from text:%{myvariable}This provides for some more advanced scripts, such as:
*Script bang !myexamplescript
*Script exec !VarSet myvariable1 "thisisgetting clever"
*Script exec !VarSet myvariable2 "%{myvariable1} and my head hurts"
*Script exec !msgbox "%{myvariable2}"
*Script ~bangIn this situation, we have defined the content of myvariable1 and then used it, along with some additional text to define the content of myvariable2. The content of myvariable2 is then shown in a message box (supplied by mzScript) on screen.
Taking it a stage further again, you can check the content of a variable against a required preset, such as*Script exec !If ["%{myvariable}" = "mypreset"] [!about]If the two match in this example, the About dialog will be displayed as before. mzScript allows other comparisons such as <, >, >=, =< and <> which can be invaluable.
mzScript also allows you to handle its variables as numbers, with multiplication and addition routines that might be useful to you.
As Phar0e as suggested, you are well advised to check out the documentation.
One thing to add - you can 'include' script files, to keep them outside step.rc.
As with any other file, simply useinclude "\script.rc"You don't need to then use the mzScript loading system (it breaks with "$LiteStepDir$......" and large numbers of files - including the files avoids both these problems).