if-then-else problem ... I Think - 20/05/06 05:28 PM
hey y'all, i am having a little trouble with if-then-else statements ... i think.
i am trying to make a script that will /splay a song, and also tell me if i have the lyrics for it. my songs are on one drive, and my lyrics on another. i have come up with something, but i cant seem to get it to tell me if the lyrics are there or not. They should be under the exact same filename that the song is in, but has a .txt extension instead of .mp3.
any help you can give me would be appreciated .. oh and i marked my comments in red.
so far i have gotten it to return something like this
the trouble with this code is is that it ONLY returns that message even when i dont have the lyrics, i want it to return "NO LYRICS for %hp" when i do not have the lyrics
ps. i commented out the splay's cause i figgured i dont need them for testing
i am trying to make a script that will /splay a song, and also tell me if i have the lyrics for it. my songs are on one drive, and my lyrics on another. i have come up with something, but i cant seem to get it to tell me if the lyrics are there or not. They should be under the exact same filename that the song is in, but has a .txt extension instead of .mp3.
any help you can give me would be appreciated .. oh and i marked my comments in red.
Code:
alias rhp { [color:red] ;sets %i to a random number which it gets from a hash table [/color] set %i $rand(0,$hget(filelist,0).item) [color:red]; sets &hp to the actual file name[/color] set %hp $hget(filelist,%i).data [color:red] ; if lyrics exists do this: this is where i grab the filename of the mp3 that i want to play, and ; munge the filename to where the text file should be, (ex. g:\metalica\metalica - one.mp3 ; ==> c:\lyrics\m\metallica - one.txt), and checks to see if it exists.[/color] if ( $exists($lydr $+ $right($left(%hp,4),1) $+ \ $+ $replace($nopath(%hp),.mp3,.txt))) = $true ) { [color:red] ; sets %ly to the text file with the lyrics[/color] set %ly $lydr $+ $right($left(%hp,4),1) $+ \ $+ $replace($nopath(%hp),.mp3,.txt) echo -a File $+($chr(35),%i,$chr(58)) $nopath(%hp) :: Lyrics Available ;splay %hp } else { echo -a File $+($chr(35),%i,$chr(58)) $nopath(%hp) :: No Lyrics Available ;splay %hp } }
so far i have gotten it to return something like this
Code:
File #33: Elton John - Rocket Man.mp3 :: Lyrics Available
the trouble with this code is is that it ONLY returns that message even when i dont have the lyrics, i want it to return "NO LYRICS for %hp" when i do not have the lyrics
ps. i commented out the splay's cause i figgured i dont need them for testing