Help - Search - Members - Calendar
Full Version: Panels UI: Using a pvar to change a button's function?
Hydrogenaudio Forums > Hosted Forums > foobar2000 > 3rd Party Plugins - (fb2k)
Keikonium
Hello,

I am trying to use a pvar switch to have a button do different things depending on the pvar number. Here is what I am trying, but it just isn't working:

CODE
$button2(35,17,0,0,208,16,
'%artist%',
'%artist%',
$ifequal($getpvar(artist_link),1,
EXEC:http'://'en.wikipedia.org/wiki/$replace(%artist%, ,_)
,
$ifequal($getpvar(artist_link),2,
EXEC:http'://'www.youtube.com/results.php?search_query=$replace(%artist%, ,+)
),)
,
TOOLTIP:"Search Wikipedia For: %artist%")


I may have the code incorrent, but with all the ) and ( and , it can get confusing.

Anyways, what I am trying to accomplish is if the pvar "artist_link" is set to 1, then the Wikipedia page loads, otherwise if it is set to 2, the YouTube page loads. I am going to repeat this for 6 sites in total.

Does anyone know how to accomplish this? Thank you smile.gif.
Purple Monkey
You have an extra comma, but you can use $select to simplify the job:
CODE
$button2(35,17,0,0,208,16,
'%artist%',
'%artist%',
$select($getpvar(artist_link),
//1
EXEC:http'://'en.wikipedia.org/wiki/$replace(%artist%, ,_),
//2
EXEC:http'://'www.youtube.com/results.php?search_query=$replace(%artist%, ,+),
//3
,
//4 etc
),
TOOLTIP:"Search Wikipedia For: %artist%")
Keikonium
Ah even better! Thank you Purple Monkey happy.gif.
Yotsuya
QUOTE(Purple Monkey @ Mar 19 2008, 20:07) *
CODE
$select($getpvar(artist_link),
//1
EXEC:http'://'en.wikipedia.org/wiki/$replace(%artist%, ,_),
//2
EXEC:http'://'www.youtube.com/results.php?search_query=$replace(%artist%, ,+),
//3
,
//4 etc
)


One thing to keep in mind is that by default the pvar will not have a value and will evaluate as 0 until you set it (I presume you are using an external function somewhere). So you may want to consider using
CODE
$select($add($getpvar(artist_link),1),
...
)


This way the routine will always perform a function even if the pvar gets unset or zeroed.
EDIT: You would also need to adjust the external function setting the pvar to 1 integer lower.
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-2008 Invision Power Services, Inc.