Page 1 of 1

Help with button scripting

Posted: 20 Feb 2023 06:50
by evangelina
Dear all, I want to add this script to a button.
2023-02-20-13-46-30.png
2023-02-20-13-46-30.png (829.94 KiB) Viewed 1050 times
I don't know how to script the check tab part. The best I can do is this:

Code: Select all

if (Get('#800')){focus "P2";if (<curpath> == "[pathX]"){focus "P1";#800;} else {tab ("new", "[pathX]");}} else {#800;focus "P2";if (<curpath> == "[pathX]"){#1001;} else {tab ("new", "[pathX]")}};
Could you please give me some help regarding how it should be written? Thank you very much!

Re: Help with button scripting

Posted: 20 Feb 2023 07:27
by highend

Code: Select all

    $pathX = "<some path>";

    if !(get("#800")) {
        #800;
    }
    focus "P2";

    $tabs = get("Tabs");
    $index = gettokenindex($pathX, $tabs, , "i");
    if ($index == 0) {
        tab("new", $pathX);
    } else {
        if (<curpath> == $pathX) {
            focus "P1";
            #800;
        } else {
            seltab $index;
        }
    }

Re: Help with button scripting

Posted: 20 Feb 2023 09:44
by evangelina
This works perfectly. Thank you so much!

Re: Help with button scripting

Posted: 14 Apr 2023 11:03
by sl23
Thanks, this adapted well to what I needed to open Drive Root in new tab without duplicating! :tup:

Code: Select all

$pathX = "D:";

    $tabs = get("Tabs");
    $index = gettokenindex($pathX, $tabs, , "i");
    if ($index == 0) {
        tab("new", $pathX);
    } else {
        seltab $index;
    }
Took a little tinkering, but exactly what I've been looking for :D