# Scripting Function - Boolean Function "empty/not empty"

**URL:** https://community.mp3tag.de/t/scripting-function-boolean-function-empty-not-empty/65555
**Category:** Support
**Created:** [August 11, 2024, 5:45am UTC](https://community.mp3tag.de/t/scripting-function-boolean-function-empty-not-empty/65555 "2024-08-11T05:45:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![rojaljelly](https://community.mp3tag.de/user_avatar/community.mp3tag.de/rojaljelly/32/17631_2.png) [@rojaljelly](https://community.mp3tag.de/u/rojaljelly)
#### Post date: [August 11, 2024, 5:45am UTC](https://community.mp3tag.de/t/scripting-function-boolean-function-empty-not-empty/65555/1 "2024-08-11T05:45:40Z")

</div>

Is there a better/more simple way for adding a "not empty" dependicie into a format string than my solution:

$if($grtr($len(%track%,0),$num(%track%,1),)

This format string should unify the track numbers by removing leading zeros, but only if the track number is not empty (because it will lead to a "0" entry in the track number). If track number tag is empty, keep it empty.  
So I'm checking if the length of the track tag is greater than 0 and then formating if true and nothing if empty.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [August 11, 2024, 6:02am UTC](https://community.mp3tag.de/t/scripting-function-boolean-function-empty-not-empty/65555/2 "2024-08-11T06:02:40Z")

</div>

You could try  
`$if2($num(%track%,1),)`

---

<div class="post-metadata">

### Author: ![rojaljelly](https://community.mp3tag.de/user_avatar/community.mp3tag.de/rojaljelly/32/17631_2.png) [@rojaljelly](https://community.mp3tag.de/u/rojaljelly)
#### Post date: [August 11, 2024, 6:19am UTC](https://community.mp3tag.de/t/scripting-function-boolean-function-empty-not-empty/65555/3 "2024-08-11T06:19:10Z")

</div>

> [@ohrenkino](#):
>
> $if2($num(%track%,1),)

This is working perfectly fine, but to be honest I don't understand the logic behind, according to the documentation.

`$if2(x,y)` ... if x is true, x is returned, otherwise y.

In this case x would be "number with 1 digit - so no leading zero)".  
How can it be that this is "true" if the tag is for example "02" at the moment. This is confusing me.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [August 11, 2024, 6:43am UTC](https://community.mp3tag.de/t/scripting-function-boolean-function-empty-not-empty/65555/4 "2024-08-11T06:43:39Z")

</div>

AFAIK the $if2() function does that what you requested: check if the addressed field is there.  
You find something similar with the `[]` in format strings which only return a result if the addressed field is there.

---

<div class="post-metadata">

### Author: ![rojaljelly](https://community.mp3tag.de/user_avatar/community.mp3tag.de/rojaljelly/32/17631_2.png) [@rojaljelly](https://community.mp3tag.de/u/rojaljelly)
#### Post date: [August 11, 2024, 6:51am UTC](https://community.mp3tag.de/t/scripting-function-boolean-function-empty-not-empty/65555/5 "2024-08-11T06:51:14Z")

</div>

Thank you very much for your help and explanation!  
My code wasn't working all the time, so I'm glad that there is a sleek function that really works.

Maybe the documentation of this function can be changed/expanded.

---

<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: [September 10, 2024, 6:51am UTC](https://community.mp3tag.de/t/scripting-function-boolean-function-empty-not-empty/65555/6 "2024-09-10T06:51:42Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
