style = 512 for inputselect()

Features wanted...
highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: style = 512 for inputselect()

Post by highend »

Most of the logic already exists in popupmenu (to handle the Caption|Data|Icon logic).
A bit of copy and paste and minimal refactoring should be able to handle this.

The good thing: XY could be a superb program starter (because it's filterable!) as well...
I'd even provide a script for it :whistle:
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: style = 512 for inputselect()

Post by admin »

The logic is fine. But this is not a case for copy and paste.

Well, anyway, what is that "Data" field supposed to do?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: style = 512 for inputselect()

Post by highend »

Caption = What to display in the inputselect() window
Data = What to return for the selected item (if Data is not used, return from Caption instead)
Icon = If not provided, return from Data (and if Data is not used, return from Caption)

I thought I've explained it within the example script on post #14?
viewtopic.php?p=160211#p160211
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: style = 512 for inputselect()

Post by admin »

Data = What to return for the selected item (if Data is not used, return from Caption instead)
I expected that but it was not totally clear from that other post. Better ask twice. :)

OK, I'm on it. It might work out... :cup:

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: style = 512 for inputselect()

Post by highend »

Great, then I can finally close my 7 year old "user configurable icon for inputselect()" request:
viewtopic.php?f=5&t=6839

:appl: :tup:
One of my scripts helped you out? Please donate via Paypal

zakhar
Posts: 148
Joined: 08 Sep 2010 21:13

Re: style = 512 for inputselect()

Post by zakhar »

:)

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: style = 512 for inputselect()

Post by admin »

zakhar wrote: :)
Yes, you will get your thing as well. Flag 2048. :)

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: style = 512 for inputselect()

Post by highend »

Very cool, thanks for adding this stuff. Lots of usecases here... :tup:

One small bug:

Code: Select all

  $list = <<<>>>
Audacity||D:\Tools\@Shortcuts\Audacity [Portable].lnk
>>>;

  text inputselect("Test: Caption|Data|Icon", $list, <crlf>, 1 + 1024);
It should return Audacity, not "<empty>". Rule: If "Data" isn't populated at all, return "Caption"
The icon is displayed correctly btw.
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: style = 512 for inputselect()

Post by admin »

This is not a missing field but an empty field. IMO it's correct to return nothing in this case.

zakhar
Posts: 148
Joined: 08 Sep 2010 21:13

Re: style = 512 for inputselect()

Post by zakhar »

admin wrote:
zakhar wrote: :)
Yes, you will get your thing as well. Flag 2048. :)
I am happy!
Thank you very much! :D

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: style = 512 for inputselect()

Post by highend »

IMO it's correct to return nothing in this case.
Ok, I can live with that.

What I'd like to see supported though: XY internal icons...

E.g.

Code: Select all

  $list = <<<>>>
7-Zip|7-Zip Selected|:del
>>>;
  text inputselect("Test: Caption|Data|Icon", $list, <crlf>, 1 + 1024);
doesn't show the icon for :del
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: style = 512 for inputselect()

Post by admin »

highend wrote:
IMO it's correct to return nothing in this case.
Ok, I can live with that.
In the meantime I rethought it. What could be the use of returning nothing? Well, I cannot see much there. I will silently change the behavior with the next release. I will update the last change log accordingly already now.

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: style = 512 for inputselect()

Post by admin »

highend wrote:What I'd like to see supported though: XY internal icons...
Coming...

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: style = 512 for inputselect()

Post by highend »

@zakhar

Code: Select all

    end compare(<xyver>, "19.00.0302", "v") == -1, "This script requires at least v19.00.0302, terminating now!";

    $sepID   = "<sep>";
    $sepIcon = ":queue";

    $subLocations = <<<>>>
%USERPROFILE%\Desktop\1
%USERPROFILE%\Desktop\2
%USERPROFILE%\Desktop\3
>>>;
    $sep = strrepeat("-", 46) . "x";

    $listOfLinks = "";
    foreach($subLocation, $subLocations, <crlf>, "e") {
        if (exists($subLocation) == 2) {
            $links = quicksearch(".lnk", $subLocation);
            if ($links) { $listOfLinks .= $links . <crlf> . "$sep|$sepID|$sepIcon" . <crlf>; }
        }
    }
    $listOfLinks .= quicksearch(".lnk /n", "%USERPROFILE%\Desktop");

    // Build "Caption|Data|Icon"
    $listOfLinks = regexreplace($listOfLinks, "^(.+\\)(.*?)(?=\r?\n|$)", "$2|$1$2|$1$2");
    // Remove (.exe).lnk in "Caption"
    $listOfLinks = regexreplace($listOfLinks, "^(.+?)(\.exe)?\.lnk\|", "$1|");

    // Sel + execute item
    $selected = inputselect("", $listOfLinks, <crlf>, 1+1024, , 400, 700);
    if ($selected == $sepID) { status "No valid entry selected, aborted!", "8B4513", "stop"; end true; }
    open $selected;
Sure, this could be done with style = 2048 as well but I personally don't want to see any ".exe.lnk" extensions...
One of my scripts helped you out? Please donate via Paypal

zakhar
Posts: 148
Joined: 08 Sep 2010 21:13

Re: style = 512 for inputselect()

Post by zakhar »

Some hours ago I have switched to v19.00.0301 :) and my script looks now like this (very simple):

Code: Select all

 $qs1 = quicksearch(".lnk","C:\Users\User\Desktop\1");
 $qs2 = quicksearch(".lnk","C:\Users\User\Desktop\2");
 $qs3 = quicksearch(".lnk","C:\Users\User\Desktop\3");
 $qs4 = quicksearch(".lnk /n","C:\Users\User\Desktop");
  
 $d = "--------------------------------------------x";
 $qs1 = "$qs1<crlf>$d<crlf>$qs2<crlf>$d<crlf>$qs3<crlf>$d<crlf>$qs4";
 
 $a = inputselect("","$qs1","<crlf>",1+2048,0,400,700,"",);
 if($a == "" || $a == $d){
 $a = 0;
 }
 end $a == 0;

 open "$a";
It works fine!

What I would like to have changed is the representation of $d - in the dialog window it has a "gray question" icon but I think that is not
a problem as I can simulate this separator element by a link to a renamed icon file. Its name would then be something like this
"--------------------------------------------x.lnk". Clicking it will end the script.

To day I would not use regexp elements ("^(.+\\)(.*?)(?=\r?\n|$)" and others) while I am not familiar with them.
I understand what they do, but not now. May be later. Therefore .lnk tail will stay a while.

Post Reply