Help - Search - Members - Calendar
Full Version: help with strings
Hydrogenaudio Forums > Hosted Forums > foobar2000 > 3rd Party Plugins - (fb2k)
mil3s
Trying to get Foobar to display my untaged files correcty in Columns UI, but I'm going insane. tongue.gif
This is what I wanna do. Separate "Artist - Track".

This is what I've got.

Artist: (this works, please let me know if there is a better way though)
$if2([%artist%],
$cut(%_filename%,$sub($strstr(%_filename%,-),2)))

Title:
$if2([%title%],
$right(... unsure.gif

Thanks for any help. smile.gif
Synthetic Soul
I can't test right now, but I believe this should do it:

ARTIST

$if2(%artist%,$substr(%_filename%,1,$sub($strchr(%_filename%,-),2)))

TITLE

$if2(%title%,$substr(%_filename%,$add($strchr(%_filename%,-),2),$len(%_filename%)))

Edit: I forgot to say: You should really use Masstagger to tag from filename, and then you wouldn't need to worry about relying on the filename for your playlist script.
mil3s
^Your code looks correct but the Title is still not right. It displays "Artist - Title". mellow.gif
mil3s
TITLE:

(this works)
$if($meta_test(title),%title%,$substr(%_filename%,$add($strchr(%_filename%,-),2),$len(%_filename%)))

(this does not... why? %title%?)
$if2(%title%,$substr(%_filename%,$add($strchr(%_filename%,-),2),$len(%_filename%)))
Synthetic Soul
Ah, silly me.

In 0.9 %title% will revert to the filename if not TITLE tag is not found.

Therefore $if2(%title%... will always return true.

As you point out $meta_test(title) is a resolve.

Sorry for the confusion.

http://wiki.hydrogenaudio.org/index.php?ti...nce#.25title.25
mil3s
Thanks for your help anyway.. biggrin.gif one last thing.
$if($meta also works without the "_test(title)" is that something that you guys added to the function, because it's doesn't say anything about this in the Titleformat Reference?

EDIT: Sorry, never mind doesn't work. tongue.gif
Synthetic Soul
%title% will return the value stored in the TITLE tag if it exists, or the file's filename if there is no such tag.

$meta(title) will return the value stored in the TITLE tag if it exists, or nothing if there is no such tag.

$meta_test(title) will return TRUE if a TITLE tag exists, and FALSE if it does not.

$meta(title), when used in a boolean sense, i.e.: "$if($meta(title),..." will return TRUE if the tag exists, and FALSE if not. In this manner it can be used in the same way as $meta_test(title).

Tagz's variables are variants. This means that they have no type, but can be converted to boolean or integer values by the script parser when used in comparisons or tests. For boolean values, generally any existing value (including 0) converts to TRUE, and nothing/null converts to FALSE.

$meta() and $meta_test().
foosion
QUOTE(Synthetic Soul @ Feb 24 2006, 02:29 PM)
Tagz's variables are variants.  This means that they have no type, but can be converted to boolean or integer values by the script parser when used in comparisons or tests.  For boolean values, generally any existing value (including 0) converts to TRUE, and nothing/null converts to FALSE.
*
Not quite, the type system of formatting scripts is not that advanced. tongue.gif

Every expression has a string and a boolean value, and variables only store string values. Whenever a function needs to interprete a value as an integer, the value has to be converted. Also, functions have to convert numeric results to string. There is no conversion for string to boolean or boolean to string.

The boolean value of all string constants (including the empty string) is false. So there really is no difference between "$if(true,<whatever>)" and "$if(,<whatever>)". However, there is difference between "$if($not(true),true,false)" and "$if($not(),true,false)": "$not(true)" evaluates to true, since "true" (as a string constant) evaluates to false. "$not()" on the other side evaluates to false, since it is called with an invalid number of arguments (zero).

I really need to write a wiki article about handling of boolean values sometime (and also update the titleformatting reference article accordingly).
mil3s
blink.gif huh.gif unsure.gif wacko.gif
foosion
Ah, one more poor soul confused by the intricacies of titleformatting semantics. Sorry about that. smile.gif
Synthetic Soul
QUOTE(foosion @ Feb 24 2006, 02:54 PM)
The boolean value of all string constants (including the empty string) is false.
huh.gif

But if I use:

$puts(myvar,TRUE)
$if($get(myvar),Y,N)


"Y" is returned. If I use:

$puts(myvar,)
$if($get(myvar),Y,N)


"N" is returned.

Similarly, if I use:

$meta(title) #
$if($meta(title),Y,N)


I get "Out There # Y"

Is this something to do with $if() rather than the boolean value of the variable?

Edit: make that two!

Edit 2: Just seen his:

QUOTE
$get(name)

Returns the value that was last stored in the variable name, if the variable was not defined (yet), it returns nothing. The truth value returned by $get indicates if the variable name was defined.
I'm feeling slightly closer to the truth...

So, basically, I am getting TRUE because the variable has been defined in both cases, not because the variable equates to TRUE?
mil3s
QUOTE(foosion @ Feb 24 2006, 09:18 AM)
Ah, one more poor soul confused by the intricacies of titleformatting semantics. Sorry about that. smile.gif
*


I wrote a Intranet in php about a year ago so I'm not a total noob. But when you don't work with programming for a long time you forget. tongue.gif
Synthetic Soul
Hmm.. I see now my statement was quite inaccurate. Apologies.

Another example:

$if(true,Y,F) #
$puts(myvar,true)
$if($get(myvar),T,F)


Returns "F # T". smile.gif

OK, I think I've got it. One to bear in mind; however, in practical use, I can still use %title%, $meta(title), or $get(myvar) as a boolean to detirmine whether they have a value or not. (looks to foosion for assurance...)

Edit: Another curiosity. You can use the "numeric" return from a function like $strstr() as boolean also.

E.g.: If %title% is "Out There":

$strstr(%title%,t) #
$strstr(%title%,x) #
$if($strstr(%title%,t),Y,N) #
$if($strstr(%title%,x),Y,N)


Returns "3 # 0 # Y # N"

So, the "0" is being treated as FALSE in this instance (with any non-zero value being TRUE).

However:

$if($strcmp($strstr(%title%,t),3),Y,N)

Returns "Y", so 3 is matching "3" in a string function.

Anyway, thanks for the correction foosion, and the education. smile.gif The more I think about it the more it makes sense, and the more useful it becomes.
foosion
"title" in "$meta(title)" is a string constant and thus its boolean value is false. The boolean value of the whole expression however is that of the "$meta" function. "$strcmp" and similar functions not only return the position of the match (as numeric value) but also a boolean value indicating whether there was a match. Keep in mind that any expression really has two independent values, a string and a truth value. The boolean value is used only for control flow; it is not "visible" in any other way.
mil3s
Discovered a bug in my code. Filenames without "-" get one character cutoff in the beginning.

How do I add $if($meta_test(title)=true OR $strchr(%_filename%,-)=false then %title% ...

Current code:
$if($meta_test(title),%title%,$substr(%_filename%,$add($strchr(%_filename%,-),2),$len(%_filename%)))
Synthetic Soul
CODE
$if($or($meta_test(title),$not($strchr(%_filename%,-))),
%title%,
$substr(%_filename%,$add($strchr(%_filename%,-),2),$len(%_filename%)))

mil3s
Thank you :happy:
foosion
$if($or($meta_test(title),$not($strchr(%_filename%,-))),...)

Oops, too slow... smile.gif
mil3s
Thanks for all help so far. smile.gif I have one more question. What are the available strings for $puts and $set_style?
for example...

back
back-selected
back-selected-no-focus
...
%_back%
%_selected_back%
%_selected_back_no_focus%

etc... These are not in the Titleformat Reference sad.gif I'm really interested in the strings for text and frame color.
foosion
QUOTE(mil3s @ Feb 25 2006, 02:25 PM)
These are not in the Titleformat Reference sad.gif I'm really interested in the strings for text and frame color.
*
I deliberately decided to only put the standard functions and fields on that page. Component-specific information should be made available in the documentation of a given component. I already added links for album list and Columns UI.
mil3s
Sorry, didn't know thery where component specific. Thanks.
mil3s
Is there a %% that display the total playlist time? If not, could it please be added. I think it would be a really useful feature. rolleyes.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.