Help with a script "Labels ON/OFF Script"

Discuss and share scripts and script files...
Post Reply
karimmaster101
Posts: 158
Joined: 20 May 2011 14:34

Help with a script "Labels ON/OFF Script"

Post by karimmaster101 »

I want to make a script that label the current path if it has no label, and remove the label if it has one. like a switch
What am I doing wrong here?

Code: Select all

 if( strpos(property("#label", "<curpath>"), "red") !=-1) {tag};
 Else {tag "red", <curpath>}

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Help with a script "Labels ON/OFF Script"

Post by highend »

tag works on the selected item(s) (if you don't provide an item list), and <curpath> isn't the selected item when you're inside of it...
and btw, the label name is case sensitive...
One of my scripts helped you out? Please donate via Paypal

karimmaster101
Posts: 158
Joined: 20 May 2011 14:34

Re: Help with a script "Labels ON/OFF Script"

Post by karimmaster101 »

highend wrote:tag works on the selected item(s) (if you don't provide an item list), and <curpath> isn't the selected item when you're inside of it...
So, what should a working script looks like?

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Help with a script "Labels ON/OFF Script"

Post by highend »

Code: Select all

    if (strpos(property("#label", <curpath>), "red") != -1) { tag "", <curpath>; }
    else { tag "Red", <curpath>; }
?
One of my scripts helped you out? Please donate via Paypal

karimmaster101
Posts: 158
Joined: 20 May 2011 14:34

Re: Help with a script "Labels ON/OFF Script"

Post by karimmaster101 »

highend wrote:

Code: Select all

    if (strpos(property("#label", <curpath>), "red") != -1) { tag "", <curpath>; }
    else { tag "Red", <curpath>; }
?
Same issue as mine; It assigns the label if it has no labels before, but it will not remove it if it already has one. Just one way, no Switch behavior.

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Help with a script "Labels ON/OFF Script"

Post by highend »

You want to remove ANY label, not only bound to the one you've used, "red", correct?
One of my scripts helped you out? Please donate via Paypal

karimmaster101
Posts: 158
Joined: 20 May 2011 14:34

Re: Help with a script "Labels ON/OFF Script"

Post by karimmaster101 »

1- If it has the same label -Red- it should remove it.
2- if it has No-label it should assigns -Red- to it.
3- if it has any other labels it should Replace them with -Red-

I hope that I delivered my idea well

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Help with a script "Labels ON/OFF Script"

Post by highend »

1- If it has the same label -Red- it should remove it.
2- if it has No-label it should assigns -Red- to it.
3- if it has any other labels it should Replace them with -Red-
That's exactly what my script does...
One of my scripts helped you out? Please donate via Paypal

karimmaster101
Posts: 158
Joined: 20 May 2011 14:34

Re: Help with a script "Labels ON/OFF Script"

Post by karimmaster101 »

That was my bad. It works now. Many thanks

Post Reply