Of course.
The following files are attached.
(1) loopcheck.mte is a test export script that illustrates the problem I encountered with $put/$get across nested loops.
(2) loopcheck_output.txt is the output file. Please open this as as a .csv file so that the output is a little easier to read.
(3) sample_library.txt is a brief listing of the sample library used to describe the problem. For illustration purposes this library contains only a very few AlbumArtists, Albums and tracks.
The sample export script is shown here:
$filename(loopcheck.txt,utf-8)
Begin End,Loop,Current %%_counter%%,Saved AAnum,Saved ALnum,Album Artist,Album Name,Title
$loop(%albumartist%)$puts(aanum,%_counter%)Begin,AlbumArtist,%_counter%,AA$num($get(aanum),5),,%albumartist%
$loop(%album%)$puts(alnum,%_counter%)Begin,Album,%_counter%,AA$num($get(aanum),5),AL$num($get(alnum),3),%albumartist%,%album%
$loop(%track%)Begin,Track,%_counter%,AA$num($get(aanum),5),AL$num($get(alnum),3),%albumartist%,%album%,%title%
$loopend()End,Track
$loopend()End,Album
$loopend()End,Albumartist
This test case reveals that the current value of the stored ($put) variables are not available to a nested $loop. Instead, the value returned via $get in the nested loop appear to be from the prior iteration of the parent loop.
In the loopcheck_output.txt this is what I am seeing:
- In the first time through parent loop - $loop(%albumartist%) – the %_counter% value is 1 and is stored into a variable.
a. Then in a child loop -$loop(%album%) – the stored value is $get’d but a zero is returned. This value is incorrect.
b. Next, the current value of %_counter% from the child loop is stored into a different variable. This value is again 1 (and is correct for the first time through the album loop.
c. Then within the active loop on %album% a third loop on %track% is started. This loop $get’s both values. Both values are returned as 0 which is incorrect.
2. In the second time through the parent %albumartist% loop, the values returned in both child loops are still incorrect, but have been incremented by 1.
3. This pattern continues for each iteration of the parent loop.
Hopefully this makes it clear.
sample_library.txt (1023 Bytes)
loopcheck.mte (540 Bytes)
loopcheck_output.txt (2.79 KB)