# Repeated %\_max\_counter% fails

**URL:** https://community.mp3tag.de/t/repeated-max-counter-fails/15608
**Category:** Export
**Created:** [March 22, 2014, 11:22pm UTC](https://community.mp3tag.de/t/repeated-max-counter-fails/15608 "2014-03-22T23:22:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [March 22, 2014, 11:22pm UTC](https://community.mp3tag.de/t/repeated-max-counter-fails/15608/1 "2014-03-22T23:22:28Z")

</div>

1 Select 10 tracks  
2 Export using this config:

```
$filename(C:\temp\temp.txt,ANSI)$loop(%title%)$loopend()
MC1 %_max_counter%,MC2 %_max_counter%,MC3 %_max_counter%.

```

Expected: MC1 10,MC2 10,MC3 10.  
Observed: MC1 10,MC2 6,MC3 .

Workaround:

```
$filename(C:\temp\temp.txt,ANSI)$loop(%title%)$loopend()
$puts(mc,%_max_counter%)
MC1 $get(mc),MC2 $get(mc),MC3 $get(mc).

```

This has not been tested in a loop and may suffer from the bug affecting variable access in a loop.

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [March 23, 2014, 7:01am UTC](https://community.mp3tag.de/t/repeated-max-counter-fails/15608/2 "2014-03-23T07:01:47Z")

</div>

> [@chrisjj](#):
>
> ... Expected: MC1 10,MC2 10,MC3 10.  
> Observed: MC1 10,MC2 6,MC3 . ...

You have to take into account that the counter memory of %\_max\_counter%, when reading immediately after a loop, the counter is automatically set to zero ... I think so.  
Obviously by your example, the counter runs into trouble when called without a previous loop, so it starts counting for itself.  
There are two mte scripts attached, which demonstrates the behaviour of %\_max\_counter% in different coding situations.  
[\_\_Export.MaxCounter.Anomalie.1.mte](https://community.mp3tag.de/uploads/default/original/2X/2/2b50b749aad64a55a54a6d7729828ca27aae5380.mte) (529 Bytes)[\_\_Export.MaxCounter.Anomalie.2.mte](https://community.mp3tag.de/uploads/default/original/2X/7/7446498e301b515e6c3f95684425abc9f05050ae.mte) (591 Bytes)

DD.20140323.0901.CET

[\_\_Export.MaxCounter.Anomalie.1.mte](https://community.mp3tag.de/uploads/default/original/2X/2/2b50b749aad64a55a54a6d7729828ca27aae5380.mte) (529 Bytes)

[\_\_Export.MaxCounter.Anomalie.2.mte](https://community.mp3tag.de/uploads/default/original/2X/7/7446498e301b515e6c3f95684425abc9f05050ae.mte) (591 Bytes)

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [March 23, 2014, 11:14am UTC](https://community.mp3tag.de/t/repeated-max-counter-fails/15608/3 "2014-03-23T11:14:56Z")

</div>

> [@DetlevD](#):
>
> Obviously by your example, the counter runs into trouble when called without a previous loop

Thanks D, but my example's calls all are with a previous loop. The failing ones are without an immediately preceding loop, but this should not affect the result. My usage accords with:

[https://docs.mp3tag.de/export](https://docs.mp3tag.de/export)  
%\_max\_counter% Maximum value of counter of the last closed loop.

The program behaviour does not. That's why I suggest there is a bug - in program or Help.
