$ifstringcontains(sub,x,y)


#1

Is there a more-concise coding for this that my:

$if($neql(0,$strstr(sub)),x,y)

?


#2

Your example has no correct syntax for the function $strstr.

DD.20110507.0458.CEST


#3

Sorry, correction:

EDIT: $if($neql(0,$strstr(string,sub)),x,y)


#4

Try:

$if($strstr(string,sub),x,y)

I believe the <> 0 should be redundant. Anything not equal 0 should evaluate to True.


#5

This doesn't work. I just tested it. There are either some glaring bugs in Mp3tag's scripting language, or else it doesn't work like any programming language that I've ever used. Looks like anything that isn't a boolean function always evaluates to FALSE.

Go back to the original and live with it.


#6

That's it!

DD.20110507.0750.CEST


#7

If there would be any re-design ever possible in Mp3tag, I would recommend to implement such a function like following.

$StrIndex

Searches a main-string for a sub-string.

Syntax:
$StrIndex (main-string, sub-string, start-pos, direction, case-sensitivity)

Parameters:
(s) main-string ... The string to be searched for a sub-string.

(s) sub-string ... The string to look for within the main-string.

(i) start-pos ... The position in the main-string to begin search. The first character of a string is position 1.

(i) (opt) direction ... The search direction. 0 is backward, 1 is forward.

(i) (opt) case-sensitivity ... Respect case notation when searching. 0 is ignore case, 1 is respect case.

Returns:
(i) position of sub-string within string, or 0 if not found.

The function searches for a "sub-string" within a "main-string".
Starting at the "start" position, it goes forward or backward depending on the value of the "direction" parameter.
It stops when it finds the "sub-string" within the "main-string", and returns its position.

A start position of 0 has special meaning depending on which direction to scan.
For forward searches, zero indicates the search should start at the beginning of the main-string.
For backward searches, zero causes it to start at the end of the main-string.

The search direction is an optional parameter, default is set to 1, which means forward search.
The case-sensitivity is an optional parameter, default is set to 1, which means respect case.

DD.20110507.0822.CEST


#8

Why would the addition of one function require a 'redesign' of Mp3tag?

I do think the entire scripting language could use a redesign, though. There are far too many ambiguities in syntax. One thing I'd like to see is requiring string constants to be enclosed in double quotes. It's silly that spaces after commas within function calls can sometimes be significant and sometimes not. The readability of many of the functions in my saved action groups is horrible, which sometimes making them very difficult to edit and debug.

Then there's the question of what should evaluate to True and False when a boolean value is expected, as this thread has pointed out. A lot of things could be cleaned up if this was sorted out properly.


#9

$ifgreater($strstr(string,sub),0,x,y)


#10

There are either some glaring bugs in Mp3tag's scripting
language, or else it doesn't work like any programming
language that I've ever used.

Certainly the latter is true for me.


#11

I do think the entire scripting language could use a redesign,
though. There are far too many ambiguities in syntax.

Agreed. It can even false-match a keyword inside a literal string!

The readability of many of the functions in my saved action groups is horrible

Mine too, but more due to the disallowance of comments and insignificant line breaks.


#12

$ifgreater($strstr(string,sub),0,x,y)

Thanks Dano.