Help - Search - Members - Calendar
Full Version: if Statement quandry
Mp3tag Forums > Mp3tag - International > Development > Web Sources Discussion
commander.atvar
Hey folks ... looking for a bit of help here on a scripting problem. I use Amazon to tag my files and when I come across an album that they no longer offer my script fails. For example ... Bare Infininty - Always Forever. My script scrapes of album price and ASIN as well as track price and ASIN. However, if the album is no longer available the script fails and will load nothing else. I am fine living without the individual prices but need the reamining information regardless of it's availability on Amazon.

So what I am looking for is a way to either check if the album is available or not and load the information according to that answer.

Here is an except of the script ... where it fails ...
CODE
# PRICE
outputto "AMAZON_ALBUM_PRICE"
findline "priceLarge\""
findinline "priceLarge"
findinline ">"
sayuntil "<"


My idea is something like this however I can not get it to work....

CODE
if findinline "priceLarge\"" = ""
   Album unavailable so do the steps to scrape ASIN's
else
   Album available so do the steps to load prices and ASIN's
endif


Any help you folks can offer would be greatly appreciated!
stevehero
QUOTE (commander.atvar @ Feb 14 2013, 01:38) *
Here is an except of the script ... where it fails ...
CODE
# PRICE
outputto "AMAZON_ALBUM_PRICE"
findline "priceLarge\""
findinline "priceLarge"
findinline ">"
sayuntil "<"

Try something like this:
CODE
# PRICE
outputto "AMAZON_ALBUM_PRICE"
findline "priceLarge\"" 1 1
findinline ">" 1 1
if "$"
movechar -1
sayuntil "<"
else
say ""
endif


The 1 1 after findline and findinline prevent the parser from stopping when string is not found and by doing an if, else, endif everything should work fine. The $ sign may need to be changed though.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.