i'm looking for some clarifications with regard to types and scripting functions and how they interact in the context of actions. Obviously, mp3tag has a notion of types. The documentation mentions a few of them in the "Scripting..." section (number, boolean, string, character...). However, there is no or little mention how these "types" play together.
For example, the boolean function $if2(x,y) is described as "if x is true, x is returned, otherwise y."
So, well.... I can assume to know how $if2 behaves iff x and y are booleans. Btw, the only way to put in booleans there is to invoke a function or expression that evaluates to a boolean, right? Wrong?
But what happens if x and/or y are
- names of undefined fields
Are they converted to boolean? How? Is it documented somewhere and I'm just unable to find it?
I searched and found $eql failure but that thread is old and the answers left me even more puzzled.
And then, there are arithmetic functions like $add(). I assume they expect numbers or lets say numeric values to operate on. Again, what happens if i throw some else on them, like boolean values, just as an example. What conversion rules are applied. Should it work or are attempts like this expected to fail?
Last, but not least, there are string functions. I assume, everything can be converted to a string. But some of the string functions work with character positions, like $strchr(). Is the index/position that is returned 0-based or 1-based (I assume counting starts with 1, and 0 is used as a special value for "not found"). Is that correct? What happens if an undefined field is referenced in a string function call - is it treated like an empty string?
Why am i asking stuff like this? Well, actually i was looking for an easy way to determine - inside an action - wether a field is empty or undefined (case 1) or wether it has a non-empty value (case 2). I wonder if i really need to use $if($eql(0,$len(%field%)) ....,case 1, case 2). I bet there is a more compact expression possible. Of course, answers to my preceeding questions are welcome too
I guess these answers would also nicely fit into the programs documentation. If I only estimate how much time i've lost in the last weeks trying to figure out how things work in mp3tag and what i could have done instead ...