Problem with popupnested()

Discuss and share scripts and script files...
Post Reply
WirlyWirly
Posts: 195
Joined: 21 Oct 2020 23:33
Location: Through the Looking-Glass

Problem with popupnested()

Post by WirlyWirly »

I'm not sure if this is a bug or not, but I'm having a small issue with using a <crlf> in inputselect() that's being loaded through a popupnested() menu.

Here's a working line of code that I load using a popupnested() menu.

Code: Select all

Connections|$files = quicksearch("ovpn", "$PORTABLEAPPS\OpenVPNPortapps\data\config\", ":::");$config = inputselect("OpenVPN"."Select the configuration file to establish a connection","$files",":::", 1 + 64 + 2048 + 4096,5:=400,6:=800,7:="OpenVPN Configuration Files",9:="<xyicons>\programs\openvpn.ico");run lax("<xyparent>\OpenVPNPortapps\openvpn-portable.exe" --silent_connection 1 --command connect "$config" )|
Results
Image

This menu works, however I would like to split the header of inputselect() into two lines between "OpenVPN"."Select the...", that way the second line is printed as non-bold. According to the help file, I should use <crlf> between the two strings, however the result is a broken popupnested() menu, as seen below.

Code: Select all

Connections|$files = quicksearch("ovpn", "$PORTABLEAPPS\OpenVPNPortapps\data\config\", ":::");$config = inputselect("OpenVPN".<crlf>."Select the configuration file to establish a connection","$files",":::", 1 + 64 + 2048 + 4096,5:=400,6:=800,7:="OpenVPN Configuration Files",9:="<xyicons>\programs\openvpn.ico");run lax("<xyparent>\OpenVPNPortapps\openvpn-portable.exe" --silent_connection 1 --command connect "$config" )|
Results
Image

Any tips for splitting the header of the inputselect() while still maintaining a working popupnested() menu?

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

Re: Problem with popupnested()

Post by highend »

Just use a different divider for the popupnested() instead of <crlf>?
One of my scripts helped you out? Please donate via Paypal

WirlyWirly
Posts: 195
Joined: 21 Oct 2020 23:33
Location: Through the Looking-Glass

Re: Problem with popupnested()

Post by WirlyWirly »

These are the parameters I'm using for popupnested()

Code: Select all

    $menu = <<<MENU

0) Sort by...||<xyicons>\other\operations\sort.ico
    0) Date Modified|Sortby 'Modified', 'clk'|<xyicons>\other\operations\sortby\datemodified.ico
    1) Name|Sortby 'Name', 'clk'|<xyicons>\other\operations\sortby\name.ico
    2) Size|Sortby 'Size', 'clk'|<xyicons>\other\operations\sortby\size.ico
    3) Extension|Sortby 'Ext', 'clk'|<xyicons>\other\operations\sortby\extension.ico
...
MENU;

$command = popupnested($menu, $x_pos, $y_pos,7:=|);
Do you mean that I should change the parameter of popupnested() to not use <crlf> between items? Are you suggesting something like this?

Code: Select all

$command = popupnested($menu, $x_pos, $y_pos,6:="|", 7:="-----");
That might work, but It'd require an entire re-write of the block-string assigned to the $menu variable. One huge line of text would be very difficult to read/edit... Unless I'm misunderstanding something?

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

Re: Problem with popupnested()

Post by highend »

You don't need to rewrite it...

Code: Select all

    $menu = <<<MENU
0) Sort by...||<xyicons>\other\operations\sort.ico
    0) Date Modified|Sortby 'Modified', 'clk'|<xyicons>\other\operations\sortby\datemodified.ico
    1) Name|Sortby 'Name', 'clk'|<xyicons>\other\operations\sortby\name.ico
    2) Size|Sortby 'Size', 'clk'|<xyicons>\other\operations\sortby\size.ico
    3) Extension|Sortby 'Ext', 'clk'|<xyicons>\other\operations\sortby\extension.ico
MENU;
    $menu = replace($menu, <crlf>, "<::>");
    $sel = popupnested($menu, 6:="<::>", 7:="|");
One of my scripts helped you out? Please donate via Paypal

WirlyWirly
Posts: 195
Joined: 21 Oct 2020 23:33
Location: Through the Looking-Glass

Re: Problem with popupnested()

Post by WirlyWirly »

Neat trick, I gave it a go but the result was the same broken popupnested() menu.

Code: Select all

    $menu = <<<MENU
...
	Connections|$files = quicksearch("ovpn", "$PORTABLEAPPS\OpenVPNPortapps\data\config\", ":::");$server = inputselect("OpenVPN".<crlf>."Select the server to connect to","$files",":::", 1 + 64 + 2048 + 4096,5:=400,6:=800,7:="OpenVPN Configuration Files",9:="<xyicons>\programs\openvpn.ico");run lax("<xyparent>\OpenVPNPortapps\openvpn-portable.exe" --silent_connection 1 --command connect "$server" )|
...

MENU;

    ...
    // Display the menu
    $menu = replace($menu, <crlf>, "<::>");
    $sel = popupnested($menu, $x_pos, $y_pos, 6:="<::>", 7:="|");
    
Image

I'm assuming that popupnested() resolves all <xyz> variables as soon as it's called, which is why it can't get them in the return as strings. I'm looking to see if there's an alternative to <crlf>, something like \n that acts as a new-line character.

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

Re: Problem with popupnested()

Post by highend »

Try this

Code: Select all

    $menu = <<<MENU
Connections|$files = quicksearch("ovpn", "$PORTABLEAPPS\OpenVPNPortapps\data\config\", ":::");$server = inputselect("OpenVPN".chr(13).chr(10)."Select the server to connect to",$files,":::", 1 + 64 + 2048 + 4096,5:=400,6:=800,7:="OpenVPN Configuration Files",9:="<xyicons>\programs\openvpn.ico");text $files;|
MENU;

    // Display the menu
    $menu = replace($menu, <crlf>, "<::>");
    $sel = popupnested($menu, , , 6:="<::>", 7:="|");
One of my scripts helped you out? Please donate via Paypal

WirlyWirly
Posts: 195
Joined: 21 Oct 2020 23:33
Location: Through the Looking-Glass

Re: Problem with popupnested()

Post by WirlyWirly »

Jackpot, we're in business, and it didn't even require the replace() function.

Code: Select all

	$menu = <<<MENU
    Connections|$ovpn_files = quicksearch("ovpn", "$PORTABLEAPPS\OpenVPNPortapps\data\config\", ":::", "n");$server = inputselect("OpenVPN".chr(13).chr(10)."Select a server", "$ovpn_files", ":::", 1 + 8 + 64 + 2048 + 4096, 5:=400, 6:=800, 7:="OpenVPN Configuration Files", 9:="<xyicons>\programs\openvpn.ico");run lax("$PORTABLEAPPS\OpenVPNPortapps\openvpn-portable.exe" --silent_connection 1 --command connect "$server" )|
MENU;

    $command = popupnested($menu, $x_pos, $y_pos, 7:="|");
Image

I looked at what the chr() function is doing and saw that you're calling a literal carriage return and then a new-line. Very neat, something like that was forming in my head but I wasn't sure how I might do it.

Thanks a bunch, I learned a couple tricks to hopefully implement in the future :beer:

-----

For anyone interested in connecting to OpenVPN through a script, here's the lines of code that I'm passing to popupnested(). Edit them to fit your needs. Keep in mind that in each .ovpn file, I've added the line auth-user-pass login-credentials, which loads the login credentials from a file called login-credentials. That's why you don't see any mention of a username/password in these lines.

Code: Select all

OpenVPN||<xyicons>\programs\openvpn.ico
    Favorites|
        Netherlands|run lax("$PORTABLEAPPS\OpenVPNPortapps\openvpn-portable.exe" --silent_connection 1 --command connect "netherlands.ovpn" )|
        Paris|run lax("$PORTABLEAPPS\OpenVPNPortapps\openvpn-portable.exe" --silent_connection 1 --command connect "paris.ovpn" )|
        New York|run lax("$PORTABLEAPPS\OpenVPNPortapps\openvpn-portable.exe" --silent_connection 1 --command connect "new_york.ovpn" )|
        -
        Japan|run lax("$PORTABLEAPPS\OpenVPNPortapps\openvpn-portable.exe" --silent_connection 1 --command connect "japan.ovpn" )|
    Disconnect|run lax("$PORTABLEAPPS\OpenVPNPortapps\openvpn-portable.exe" --command disconnect_all)|
    -
    Servers|$ovpn_files = quicksearch("ovpn", "$PORTABLEAPPS\OpenVPNPortapps\data\config\", ":::", "n");$server = inputselect("OpenVPN".chr(13).chr(10)."Select a server", "$ovpn_files", ":::", 1 + 8 + 64 + 2048 + 4096, 5:=400, 6:=800, 7:="OpenVPN Configuration Files", 9:="<xyicons>\programs\openvpn.ico");run lax("$PORTABLEAPPS\OpenVPNPortapps\openvpn-portable.exe" --silent_connection 1 --command connect "$server" )|
    Exit|run lax("$PORTABLEAPPS\OpenVPNPortapps\openvpn-portable.exe" --command exit)|

Post Reply