CODE
# Primary Cover - backasswards because FindInLine
# does exception if nothing found
FindInLine "<artists>"
MoveChar -18
If "</images>"
# We sure now that primary image exists
OutputTo "COVERURL"
GotoChar 1
FindInLine "type=\"primary\" uri=\""
SayUntil "\""
EndIf
# does exception if nothing found
FindInLine "<artists>"
MoveChar -18
If "</images>"
# We sure now that primary image exists
OutputTo "COVERURL"
GotoChar 1
FindInLine "type=\"primary\" uri=\""
SayUntil "\""
EndIf
Luckily <artists> tag in this particular case always exists. If less lucky, the puzzle could be unresolvable.
It would be great to have something like, for example, IfExists operator:
CODE
# Primary Cover
IfExists "<image type=\"primary\""
OutputTo "COVERURL"
GotoChar 1
FindInLine "<image type=\"primary\" uri=\""
SayUntil "\""
EndIfExists
IfExists "<image type=\"primary\""
OutputTo "COVERURL"
GotoChar 1
FindInLine "<image type=\"primary\" uri=\""
SayUntil "\""
EndIfExists