Page 1 of 1

Help with a script "Labels ON/OFF Script"

Posted: 04 Jul 2018 07:35
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>}

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

Posted: 04 Jul 2018 07:52
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...

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

Posted: 04 Jul 2018 07:57
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?

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

Posted: 04 Jul 2018 08:00
by highend

Code: Select all

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

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

Posted: 04 Jul 2018 08:09
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.

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

Posted: 04 Jul 2018 08:11
by highend
You want to remove ANY label, not only bound to the one you've used, "red", correct?

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

Posted: 04 Jul 2018 08:15
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

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

Posted: 04 Jul 2018 08:28
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...

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

Posted: 04 Jul 2018 08:41
by karimmaster101
That was my bad. It works now. Many thanks