Stripping an mzvar... Thread last updated on 2007-11-12 00:56:52

Posted by member 256241 on 2007-11-11 16:40:04

Hello people.

I have made a quicklaunch type thing, and I want it to extract a likely name from the filename. I have a value with a path in it, ie: c:\folder\file.exe...

I only want text after the last backslash, and before the last period (becoming "file")


*script exec !varset path "[afterLast(%{path}, ' \ ')]" doesn't work. I don't know how to get it to work with a variable.

Can anyone give me any pointers with this?

Thanks for reading.

Posted by member 212670 on 2007-11-11 22:02:41 link

Try this out...
*Script bang !testbang
*Script exec !varSet myvar "c:\folder\file.exe"
*Script exec !parseEvars !alert "%[beforeLast(afterLast('%{myvar}', '\'), '.')]%"
*Script ~bang

You'll notice you were missing !parseEvars and enclosing the text sequence in %. Also, note the syntax I used for nesting the "afterLast" part.

Posted by member 256241 on 2007-11-11 22:30:20 link

Nice :).

Thanks a lot xcal, it works perfectly. I didn't know about using %[ ]%

Exactly when are they required?

Posted by member 212670 on 2007-11-12 00:56:52 link

If you want to be using a [textEscapeSequence] in a !bang command, you need the "%" to tell !parseEvars to parse it. When you're using a [textEscapeSequence] just as a label text, xlabel automatically knows to parse it, so you don't need "%" for that.