Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Building a Columns UI design from scratch (Read 37291 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Building a Columns UI design from scratch

Reply #25
Small update.

Mainly typos, some small details and updated comments referring to Foobar2000 0.9 being beta. No changes to the scripts.

And thx again for all the feedback so far.

Thank you bro. Truly nice tutorial!!!

Building a Columns UI design from scratch

Reply #26
ok, so maybe i shouldn't but i've been using your strings and trying to make me a decent custom string (i really don't like what you did with your foobar, so i started deviating right away ).
it's a shame that you don't teach the "proper" language, and i've been having some difficulties, so if that could be added. What i mean is adding the meaning of commas, parenthesis etc within the language, you made a nice deal there in the "Introduction" but then suddenly we're left with no explanation on how to properly "close" lines.

*EDIT*


well damn, foosion helped me out in IRC ! Thanks a lot to foosion, and well, i figured it out by using Notepad++ and finnaly figuring out the syntax ...

That little snippet of criticism still applies. Just a link to a fuller explanation of the language would be great.

Building a Columns UI design from scratch

Reply #27
Hi, Sprafa.

I see where you're coming from. You don't close lines in Tagz because there are no lines for the parser. Theoretically you can delete all line breaks from a script and it keeps working. Of course, reading such a thing would be extremely tedious.
The things you really open and close are tag fields, strings and functions. The first two are easy: %field name% and 'some text'. Functions can be more tricky because they may be nested, i.e. a function contains a seconds functions which possibly again contains a third one. However, the logic always stays the same.

All arguments of a function are enclosed in a set of brackets and the arguments separated with commas.

Code: [Select]
$fnc(arg1,arg2,arg3)

No problem here I suppose. You just open the bracket, list the arguments and then close the bracket. The function always ends with its closing bracket - even when there's no arguments like with tab().

The problem starts when an argument again is a function because the you have two sets of brackets to take care of. Let's extend the example a little:
arg3 = $bar(argA,argB)

Code: [Select]
$fnc(arg1,arg2,$bar(argA,argB))

Note the two closing brackets at the end. The first one belongs to $bar, the second one to $fnc. And if we substitute again
argB = $bla(argX,argY)
this is the result:
Code: [Select]
$fnc(arg1,arg2,$bar(argA,$bla(argX,argY)))

You see the logic behind this?

Your script. Its structure should be:
Code: [Select]
$if(condition,$select(condition,action1,action2))

But you did:
Code: [Select]
$if(condition,$select(condition,action1))action2

adding the track 2 code outside the whole if-select construction, executing it for every line. That's the same as writing instead of the last example:

Code: [Select]
Correct:  $fnc(arg1,arg2,$bar(argA,$bla(argX,argY)))
Your way: $fnc(arg1,arg2,$bar(argB))$bla(argX,argY)


Your script should be this:
Code: [Select]
$if($get_global(isAlbum)
,
//ALBUM
$select(%tracknumber%
,
//Track 1
$tab()$if2(%album%,'<no album>')'   '['Disc '%disc%]$if2(%album date%,[%date%])$tab()
,
//Track 2
'   '$if2(%album artist%,'<no artist>')
' '$upper(%codec%)
' '$upper(%bitrate%) 'KBPS'
))


One tip for writing such constructions. Even for simple ifs I always start like this
Code: [Select]
$if(
)

and then enter everything in between. Otherwise it's really easy to get lost between all the brackets.

Hm, now, probably it is worth adding some words about nesting to the tutorial. I'll keep that in mind for the next update.

Brother John

Building a Columns UI design from scratch

Reply #28
Thank You, been wanting to learn this for quite sometime. Put that in my favorites and will get around to it sometime later today. Thanks again for putting all your time and effort into a great tutorial.

~nightwingz

Building a Columns UI design from scratch

Reply #29
Hi - once again I can't thank you enough for the great head-start these tutorials give us newbies.

But I wanted to point out that there's actually a simpler way to have an animated tracknumber position during playback. I got this from another tutorial site (which, sadly, is not nearly as good as yours) listed along with yours in the foobar2000 wiki.

The code I'm using is this:

//If track is playing, put a spinning thingy
$if($or(%isplaying%,%ispaused%),                                                                    <--
$select($add(1,$mod(%playback_time_seconds%,4)),--,\,|,/),                              <--
//Otherwise we want to put in a tracknumber, padded to two places
$if($get_global(isAlbum),
$ifgreater(%tracknumber%,9,
%tracknumber%,
'0'$num(%tracknumber%,1)
))
)

Again, I didn't come up with this myself, so I can't explain why that works, but it does.

Building a Columns UI design from scratch

Reply #30
Your example essentially uses the same programming technique as mine. What makes it easier is the much simpler animation.
The real difference is the way of dealing with $select's inability to handle zero. Here $add is used to avoid zeros; I catch them with an an $ifequal outside the $select.

Brother John

Building a Columns UI design from scratch

Reply #31
Thank you brother john for the great tutorial.

being a tactile learner and  following your guide made me really understand TAGZ

Cheers!

 

Building a Columns UI design from scratch

Reply #32
Hi, i'm quite new to this, but i found what i think is an error with your tutorial.

In the script for designating Album Tracks, you refer to %album tracks%.  That doesn't seem to work with 9.3.1.  I just replaced it with %totaltracks% and it worked fine.  I'm not sure if other people who are  also new would figure that out.

Otherwise, this tutorial is fantastic and it really gave me a good start.  Thank you for the time and effort you put into this!

Building a Columns UI design from scratch

Reply #33
Oh, well, I'm afraid those tag name discussions will never end... *sigh*
[stubborn]No, I will not make any changes just because of tag name issues.[/stubborn]

The example script uses %album tracks% exclusively and of course will only work if this name is used in your files. Foobar2000's masstagger uses %totaltracks% instead, so it's not too unlikely that the script won't work unchanged for you. That's ok though. The script was created to illustrate how the TAGZ language works. It's not intended to work out of the box.

Brother John

Building a Columns UI design from scratch

Reply #34
ooh i see it has to do with the tags on my files!  i thought they changed the syntax or something in the new version of foobar.

Building a Columns UI design from scratch

Reply #35
Hi Brother John!

First of all your tutorial is REALLY neat. There's only one thing concerning the track number column.
Why do you use this piece of code...

Code: [Select]
$ifgreater(%tracknumber%,9,
%tracknumber%,
'0'$num(%tracknumber%,1)
)

when

Code: [Select]
$num(%tracknumber%,2)

does exactly the same thing. That's why this function exists, to pad a number with leading zeros (as you  explain in the according section of your tutorial).

I really like your tutorial, otherwise I wouldn't bother posting. Thanks for the good work.

greetz

Building a Columns UI design from scratch

Reply #36
Quote
Code: [Select]
$num(%tracknumber%,2)

$num() is not necessary as %tracknumber% is automatically padded to two digits (read: field remappings).

Building a Columns UI design from scratch

Reply #37
Have a look at the fourth paragraph after the code. It's explained there.

Quote
You might have noticed that the $ifgreater() does the zero-padding manually: displaying just the number when the number is at least 10 and padding with a zero below. We use this manual method because we later want to display the leading zero in a different colour. But we couldn’t access it individually using automatic padding.

"Automatic padding" means using %tracknumber% alone and rely on field remapping. It will become clear when you look at the colour scheme chapter. There colour code gets inserted around the '0'.

Building a Columns UI design from scratch

Reply #38
I thought I lost this thread  Could a mod sticky this?  I would have loved to find it when I first started with foobar.

Building a Columns UI design from scratch

Reply #39
Wanted to thank Brother John also,cos it's his tutorial that gave me a boost into the foobar's world in a first place.
Favourite artist:CD-R
Favourite album:700MB