Nesting of Do Loops


#1

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...


#2

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


#3

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... :confused:


#4

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


#5
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. :slight_smile:

And according to the official documentation "Nesting of Do commands is not allowed". I actually haven't tried it, though. In might work in spite of that (probably outdated) info.