Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Panels UI: Using a pvar to change a button's function? (Read 3097 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Panels UI: Using a pvar to change a button's function?

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: [Select]
$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 .
Song List: keikoniumboards.ke.funpic.org/files/songlist.html

Panels UI: Using a pvar to change a button's function?

Reply #1
You have an extra comma, but you can use $select to simplify the job:
Code: [Select]
$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%")

Panels UI: Using a pvar to change a button's function?

Reply #2
Ah even better! Thank you Purple Monkey .
Song List: keikoniumboards.ke.funpic.org/files/songlist.html

 

Panels UI: Using a pvar to change a button's function?

Reply #3
Code: [Select]
$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]
$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.