# user defined variables

**URL:** https://community.mp3tag.de/t/user-defined-variables/2175
**Category:** Support
**Created:** [August 9, 2005, 12:21pm UTC](https://community.mp3tag.de/t/user-defined-variables/2175 "2005-08-09T12:21:35Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![rmg](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/278dde/32.png) [@rmg](https://community.mp3tag.de/u/rmg)
#### Post date: [August 9, 2005, 12:21pm UTC](https://community.mp3tag.de/t/user-defined-variables/2175/1 "2005-08-09T12:21:35Z")

</div>

Hi

I'm trying to do smth like an avergage bitrate over a catalog. I tried looping all the mp3s and adding their bitrates to one variable, but if I want to display the result after the loop, the variable is empty? ☹ How to accomplish this task?  
How to globalize the variable?

Next, I want to display certain information if the bitrate is VBR and other info if it's CBR. The question is, how to check if it's CBR or VBR?

Thanks in advance  
rmg

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [August 9, 2005, 12:40pm UTC](https://community.mp3tag.de/t/user-defined-variables/2175/2 "2005-08-09T12:40:02Z")

</div>

1. 

My html\_dano\_01\_ex\_mp3tag config has an average bitrate calculation.  
[/t/1495/1](https://community.mp3tag.de/t/1495/1)

1. 

%\_vbr%

---

<div class="post-metadata">

### Author: ![rmg](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/278dde/32.png) [@rmg](https://community.mp3tag.de/u/rmg)
#### Post date: [August 9, 2005, 1:05pm UTC](https://community.mp3tag.de/t/user-defined-variables/2175/3 "2005-08-09T13:05:41Z")

</div>

Oh, thx for the average bitrate calculator. It works.

%\_vbr% prints CBR or VBR for mp3, but how to make a conditional sentence for checking it. Like $if(%\_vbr%==CBR,then,else)\<-this one doesn't work.

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [August 9, 2005, 1:14pm UTC](https://community.mp3tag.de/t/user-defined-variables/2175/4 "2005-08-09T13:14:23Z")

</div>

$if($eql(%\_vbr%,CBR),then,else) I think.  
See the help file for more information.

---

<div class="post-metadata">

### Author: ![rmg](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/278dde/32.png) [@rmg](https://community.mp3tag.de/u/rmg)
#### Post date: [August 9, 2005, 4:07pm UTC](https://community.mp3tag.de/t/user-defined-variables/2175/5 "2005-08-09T16:07:46Z")

</div>

Ok, now I can check the CBR/VBR status, but a new problem occured ☹

I loop through the mp3 file sizes and measure their length. What I'd want to do is to get the longest length in a variable, but somehow it doesn't seem to work.

The code I use:  
$loop(%\_filename\_ext%)$iflonger(%\_file\_size%,$get(length),$puts(length,$len(%\_file\_size%)),)$loopend()get(length)

The results are 7,7,7,7,7,7,7,8,7,7, but the variable somehow remembers the 7 and not the 8, at least when I try to use it outside the loop. Please tell me what am I missing here?

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [August 9, 2005, 6:41pm UTC](https://community.mp3tag.de/t/user-defined-variables/2175/6 "2005-08-09T18:41:42Z")

</div>

Try:  
$loop(%\_filename\_ext%)$puts(length,$iflonger(%\_file\_size%,$get(length),$len(%\_file\_size%),$get(length)))$loopend()  
$get(length)

_This should be ok._

---

<div class="post-metadata">

### Author: ![rmg](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/278dde/32.png) [@rmg](https://community.mp3tag.de/u/rmg)
#### Post date: [August 10, 2005, 9:37am UTC](https://community.mp3tag.de/t/user-defined-variables/2175/7 "2005-08-10T09:37:25Z")

</div>

> [@](#):
>
> Try:  
> $loop(%\_filename\_ext%)$puts(length,$iflonger(%\_file\_size%,$get(length),$len(%\_file\_size%),$get(length)))$loopend()  
> $get(length)
> 
> _This should be ok._
> 
> \<{POST\_SNAPBACK}\>

Thanks, this piece of code works.  
But still, what is the big difference between these two codes?

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [August 10, 2005, 10:26am UTC](https://community.mp3tag.de/t/user-defined-variables/2175/8 "2005-08-10T10:26:58Z")

</div>

> [@](#):
>
> But still, what is the big difference between these two codes?

I leave that to Florian to explain 😛  
It has some thing to do with the order of the code evaluation but I can't really explain it.

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 9, 2026, 12:19pm UTC](https://community.mp3tag.de/t/user-defined-variables/2175/9 "2026-02-09T12:19:26Z")

</div>


