Export: Use of $put/$get across nested loops?

I think I have all said and written about the visibility of $put/$puts some time ago.
There you can find a mte script, which demonstrates the behaviour ...
Check if field value is identical for all selected tracks

Maybe I'm blind to this thread problem because I've been taking such a long break with Mp3tag export scripting, but a further test on Mp3tag v2.81 makes me fear that something is wrong.

Run this export script and check the result ...

$filename($getEnv('USERPROFILE')'\Desktop\LoopCheck.txt',UTF-8) '20170225.Mp3tag.LoopCheck' $loop(1,1)'aanum='$put(aanum,0)$loopend() 'aanum='$get(aanum)' ???' '---' '#loop albumartist'$loop(%ALBUMARTIST%) 'aaname='%ALBUMARTIST% 'aanum='$put(aanum,$add(1,$get(aanum))) '#loop album'$loop(%ALBUM%) 'aaname='%ALBUMARTIST% 'aanum='$get(aanum) 'album='%ALBUM% $loopend()'#loopend album' $loopend()'#loopend albumartist'

I did the test on 3 files, having fields and values ...
ALBUMARTIST=AlbumArtist_1; ALBUM=Album_1_1
ALBUMARTIST=AlbumArtist_2; ALBUM=Album_2_1
ALBUMARTIST=AlbumArtist_2; ALBUM=Album_2_2

... and got this output ...

20170225.Mp3tag.LoopCheck aanum=0 aanum=2 ??? --- #loop albumartist aaname=AlbumArtist_1 aanum=1 #loop album aaname=AlbumArtist_1 aanum=0 album=Album_1_1 #loopend album aaname=AlbumArtist_2 aanum=2 #loop album aaname=AlbumArtist_2 aanum=1 album=Album_2_1 aaname=AlbumArtist_2 aanum=1 album=Album_2_2 #loopend album #loopend albumartist

Have a look at the values of variable aanum, ...
there might be different failures, ...
especially a calculation failure of -1 when the variable is read within another loop construct.

DD.20170225.1028.CET

I did another test with a modified export script ...
... which creates a better result ...

$filename($getEnv('USERPROFILE')'\Desktop\LoopCheck.2.txt',UTF-8) '20170225.Mp3tag.LoopCheck.2' $loop(0)'aanum='$put(aanum,0) 'aanum='$get(aanum)' '$if($eql(0,$get(aanum)),'','') '---' '#loop albumartist'$loop(%ALBUMARTIST%) 'aaname='%ALBUMARTIST% 'aanum='$put(aanum,$add(1,$get(aanum))) '#loop album'$loop(%ALBUM%) 'aaname='%ALBUMARTIST% 'aanum='$add(1,$get(aanum)) 'album='%ALBUM% $loopend()'#loopend album' $loopend()'#loopend albumartist' $loopend()

... and got this output ...

20170225.Mp3tag.LoopCheck.2 aanum=0 aanum=0 --- #loop albumartist aaname=AlbumArtist_1 aanum=1 #loop album aaname=AlbumArtist_1 aanum=1 album=Album_1_1 #loopend album aaname=AlbumArtist_2 aanum=2 #loop album aaname=AlbumArtist_2 aanum=2 album=Album_2_1 aaname=AlbumArtist_2 aanum=2 album=Album_2_2 #loopend album #loopend albumartist

DD.20170225.1655.CET