mzScript, beginning and end of string Thread last updated on 2004-08-09 02:35:56

Posted by member 12025 on 2004-08-08 02:35:54

With mzScript, is there a way to check the first one or two characters in a string, and the last one or two?
As in,
!checkstuff "yeah-bob"
, and checking to see if it starts with "ye" and ends with "ob", without knowing what is in between?
Is there any other module that could help do this, either?

If it helps, I'm ultimately looking to make a multipurpose, potentially recursive, script (if possible) to simulate the use of functions that can return values, so I can design less kludgy scripts overall, that will hopefully be easier to modify and debug. Oh, and I'm bored :).

Posted by member 37809 on 2004-08-08 09:10:02 link

That looks like an iffy way to parse strings :p

Sounds like it should be done at the module level.

If you insist, there's possibly a way to do it with current scripting:
With textedit, write your text to a file and remove the middle. Then use xLabel's !LabelInfoExport and *line*() function(s) on that file to read it back into a variable.

It's ridiculous the things I'm trying these days :)

Posted by member 12025 on 2004-08-08 09:29:33 link

Well, that would involve HD access, slowing things down a good bit. If I could figure out how, I might try a module :). I actually did think of that, and it might not be that bad, given no GUI stuff would be needed. I just managed to get the source, so now I'll see how far over my head things can get today :).

So far I've tried just doing extra expansions (I want to do more, but that's the most annoying thing I want to deal with), and the script calling itself again kills LS (no errors, just bye-bye litestep), and doing it by looping with more literal replacements, I get into special cases easily and it just doesn't do quite right, at least when I need to do multiple replacements at the same level.

Since using %{} is just asking for trouble w/ mzScript (tried that already, many times), I was working with < and >, and yes, using xLabel to do some of it.

Posted by member 144980 on 2004-08-08 11:22:10 link

i've never used mzscript so i ain't 100% on how it works but doesn't it just let you string together predefined bangs to create a new bang?

if thats the case couldn't you use a textedit regex bang to check the string?

i know that ^ checks the start of the string, i would imagine there's an equivalent for the end of a string

Posted by member 12025 on 2004-08-08 13:19:55 link

mzScript lets you separate a string into two parts at a time by one character. PITA, as I need to make no less than three parts per level of expansion.

Textedit I'm not too familiar with, but if I need to save to the HD and load from the HD, that is unacceptable. Each time a task is added or removed from the taskbar, go to the HD at least four times? Each time an item is added or remove from the systray go to the HD six times? Twice for changing any VWM setting, etc..

I'll use ( and ) here, because they are fresh in my mind, and easier to read than %{ and }.

!varSet (tmp)BoxImageLeftEdge "((style)_(thick)_edge_(grip)_left)"

Where style, thick and, grip are set separately, but from the same base (tmp, which is equal to the only parameter passed). Let's say tmp is VWM. This is working fine. What I want...
!eval !varSet (tmp)BoxImageLeftEdge "(((tmp)style)_((tmp)thick)_edge_((tmp)grip)_left)"

So it's one line instead of x+3. That becomes
expansion 1 (maybe more than one step, but one level): "((VWMstyle)_(VWMthick)_edge_(VWMgrip)_left)"
2: "(singlebrace_1_edge_2_left)"
3" "1"

I have a way to do it now, but I may as well just do what I have been doing rather than use it (very, very long version that goes overboard in making lists--should work, but big).

(I'm beginning to think maybe this should have been in the code section :))

Posted by member 37809 on 2004-08-08 15:34:59 link

so you want recursive var expansion...
it should be in the next release of mzscript... :/

so that's what your !eval tries to do with parentheses?
that's cool. i'd like to see it.

Posted by member 12025 on 2004-08-09 02:35:56 link

I would too--I'm using multiple levels of expansion more and more now. I may just try the long method and see if it can be shortened.