# Nesting of Do Loops

**URL:** https://community.mp3tag.de/t/nesting-of-do-loops/11085
**Category:** Web Sources Discussion
**Created:** [November 8, 2010, 8:14pm UTC](https://community.mp3tag.de/t/nesting-of-do-loops/11085 "2010-11-08T20:14:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![sigloiv](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/848f3c/32.png) [@sigloiv](https://community.mp3tag.de/u/sigloiv)
#### Post date: [November 8, 2010, 8:14pm UTC](https://community.mp3tag.de/t/nesting-of-do-loops/11085/1 "2010-11-08T20:14:53Z")

</div>

Is there any sort of workaround for the lack of support for nested do loops? I'm having trouble pulling an indefinite amount of various artists from a particular website without some sort of conditional loop inside of another...

---

<div class="post-metadata">

### Author: ![pone](https://community.mp3tag.de/user_avatar/community.mp3tag.de/pone/32/272_2.png) [@pone](https://community.mp3tag.de/u/pone)
#### Post date: [November 8, 2010, 9:47pm UTC](https://community.mp3tag.de/t/nesting-of-do-loops/11085/2 "2010-11-08T21:47:17Z")

</div>

Most scripts work here with if ... else ... inside the loop.  
Can you give some more details (html, skript)? So maybe I can help you.

---

<div class="post-metadata">

### Author: ![sigloiv](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/848f3c/32.png) [@sigloiv](https://community.mp3tag.de/u/sigloiv)
#### Post date: [November 24, 2010, 5:48pm UTC](https://community.mp3tag.de/t/nesting-of-do-loops/11085/3 "2010-11-24T17:48:49Z")

</div>

> [@pone](#):
>
> Most scripts work here with if ... else ... inside the loop.  
> Can you give some more details (html, skript)? So maybe I can help you.

Unfortunately, I can't give very specific details (the script I'm working on, which mostly works, is not allowed on this site...) Basically, the script is scanning through a tracklist of indefinite length with multiple fields (including track number, title, and composer). One of those fields (composer) also has an indefinite number of datum, hence the need for another do loop inside the tracklist loop.

I'm thinking about just adding enough nested if loops to cover a maximum of 4 or 5 composers per track. It's kind of hacky, but it should work. I just wish I could nest do loops... 😕

---

<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: [November 24, 2010, 6:09pm UTC](https://community.mp3tag.de/t/nesting-of-do-loops/11085/4 "2010-11-24T18:09:55Z")

</div>

> [@sigloiv](#):
>
> ... Basically, the script is scanning through a tracklist of indefinite length with multiple fields (including track number, title, and composer). One of those fields (composer) also has an indefinite number of datum, hence the need for another do loop inside the tracklist loop. ...

I do not know whether Mp3tag "Source" Scripting Language supports nested "do-while" loops, did you try this already?

The following code is a cut out from some olde code study and has no concrete worth in reality.  
Maybe it could be useful to learn something from .. no guarantee at all.

```
# Track/Artist/Composer
GotoLine 1
FindLine "<div id=\"albumpage\">" 1 1
FindInLine "class=\"subtitle\"" 1 1
If "\""
   # Normal
   FindLine "<TD class=\"cell-img\" valign=\"top\">"
   Do
      FindLine "word-wrap:break-word"
      MoveLine 1

   # Composer
      OutputTo "Composer"
      FindLine "<TD class=\"cell\">"
      FindLine "</tr>"
      MoveLine 1
      If "<div class=\"expand\"></div>"
         MoveLine -6
         IfNot "<TD class"
            SayRest
         EndIf
      Else
         FindLine "Composed by:"
         FindInLine "top\">"
         SayUntil "<"
      EndIf

      Say "|"

      FindLine "></div>"
      MoveLine 1
   While "<tr class=\"visible\""
Else
   # Various Artists
   FindLine "<TD class=\"cell-img\" valign=\"top\">"
   Do
      # Tracks
      FindLine "word-wrap:break-word"
      FindLine "<a href=\"/cg/amg.dll"
      FindInLine "\">"

      # Artist
      FindLine "<TD class=\"cell\">"
      JoinUntil "</TD>"
      KillTag "*"
      OutputTo "Artist"
      SayRest
      Say "|"

      FindLine "></div>"
      MoveLine 1
   While "<tr class=\"visible\""
EndIf

```

DD.20101124.2010.CET

---

<div class="post-metadata">

### Author: ![sigloiv](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/848f3c/32.png) [@sigloiv](https://community.mp3tag.de/u/sigloiv)
#### Post date: [November 24, 2010, 8:03pm UTC](https://community.mp3tag.de/t/nesting-of-do-loops/11085/5 "2010-11-24T20:03:25Z")

</div>

QUOTE (DetlevD @ Nov 24 2010, 11:09) \<{POST\_SNAPBACK}\>

I do not know whether Mp3tag "Source" Scripting Language supports nested "do-while" loops, did you try this already?

The following code is a cut out from some olde code study and has no concrete worth in reality.  
Maybe it could be useful to learn something from .. no guarantee at all.

```
# Track/Artist/Composer
GotoLine 1
FindLine "<div id=\"albumpage\">" 1 1
FindInLine "class=\"subtitle\"" 1 1
If "\""
   # Normal
   FindLine "<TD class=\"cell-img\" valign=\"top\">"
   Do
      FindLine "word-wrap:break-word"
      MoveLine 1

   # Composer
      OutputTo "Composer"
      FindLine "<TD class=\"cell\">"
      FindLine "</tr>"
      MoveLine 1
      If "<div class=\"expand\"></div>"
         MoveLine -6
         IfNot "<TD class"
            SayRest
         EndIf
      Else
         FindLine "Composed by:"
         FindInLine "top\">"
         SayUntil "<"
      EndIf

      Say "|"

      FindLine "></div>"
      MoveLine 1
   While "<tr class=\"visible\""
Else
   # Various Artists
   FindLine "<TD class=\"cell-img\" valign=\"top\">"
   Do
      # Tracks
      FindLine "word-wrap:break-word"
      FindLine "<a href=\"/cg/amg.dll"
      FindInLine "\">"

      # Artist
      FindLine "<TD class=\"cell\">"
      JoinUntil "</TD>"
      KillTag "*"
      OutputTo "Artist"
      SayRest
      Say "|"

      FindLine "></div>"
      MoveLine 1
   While "<tr class=\"visible\""
EndIf

```

DD.20101124.2010.CET

Yeah, I've held onto this code for awhile, and it's actually what my script is based on. Thanks, though. 🙂

And according to the [official documentation](https://docs.mp3tag.de/tag-sources) "Nesting of Do commands is not allowed". I actually haven't tried it, though. In might work in spite of that (probably outdated) info.
