Page 1 of 1
why this script don't work?
Posted: 13 Jan 2026 06:20
by k20
Right-click on line number > Run Script
Code: Select all
$sel = get("SelectedItemsPathNames");
if ($sel == "") { msg "No file selected."; exit; }
$numSel = count(split($sel, "\n"));
// Build menu manually as here-doc-like string (safe)
$menu = "";
// Define apps: [name, exe, mode]
@entries = (
["Notepad++", "<xydrive>\\Portables\\~Viewers\\notepad++\\notepad++.exe", "any"],
["ImHex", "<xydrive>\\Portables\\~Viewers\\ImHex\\ImHexPortable.exe", "single"]
);
foreach ($entry in @entries) {
$name = $entry[0];
$exe = $entry[1];
$mode = $entry[2];
if (!exists($exe)) { continue; }
if ($mode == "single" && $numSel > 1) { continue; }
// Escape backslashes for safety (though usually not needed)
// Use single quotes inside run '' to avoid escaping
$cmd = "run '" . $exe . " <selitems>'";
$menu .= $name . "|" . $cmd . "|" . $exe . "\n";
}
if ($menu == "") {
msg "No apps available.", "POM";
exit;
}
$chosen = popupnested($menu,,,,,,,|);
if ($chosen != "") {
load $chosen,, s;
}
Re: why this script don't work?
Posted: 13 Jan 2026 08:29
by RalphM
Where does the @entries come from?

Re: why this script don't work?
Posted: 13 Jan 2026 08:31
by highend
Ask that the AI that created it and tell her to not hallucinate...
Re: why this script don't work?
Posted: 13 Jan 2026 15:52
by k20
Yes! Is from AI... I update my script.
I padding each line in the script from the beggining with " ". Works!
The script runs... but stop at "Invalid Parameter: $entry as $entries" ...
Code: Select all
$sel = get("SelectedItemsPathNames");
if ($sel == "") { msg "No file selected."; exit; }
$numSel = count(split($sel, "\n"));
// Define apps: [name, exe, mode]
$entries = array(
array("Notepad++", "<xydrive>\\Portables\\~Viewers\\notepad++\\notepad++.exe", "any"),
array("ImHex", "<xydrive>\\Portables\\~Viewers\\ImHex\\ImHexPortable.exe", "single")
);
// Build menu manually as here-doc-like string (safe)
$menu = "";
foreach ($entry as $entries) {
$name = $entry[0];
$exe = $entry[1];
$mode = $entry[2];
if (!exists($exe)) { continue; }
if ($mode == "single" && $numSel > 1) { continue; }
// Escape backslashes for safety (though usually not needed)
// Use single quotes inside run '' to avoid escaping
$cmd = "run '" . $exe . " <selitems>'";
$menu .= $name . "|" . $cmd . "|" . $exe . "\n";
}
if ($menu == "") {
msg "No apps available.", "POM";
exit;
}
$chosen = popupnested($menu,,,,,,,|);
if ($chosen != "") {
load $chosen,, s;
}
Re: why this script don't work?
Posted: 14 Jan 2026 03:34
by k20
working code:
Code: Select all
// Get count to check for 'single' mode logic
$numSel = get("CountSelected");
if ($numSel == 0) { echo "No file selected."; }
// Use native array as requested
$entries = array(
"Notepad++|<xydrive>\Portables\~Viewers\notepad++\notepad++.exe|any",
"ImHex|<xydrive>\Portables\~Viewers\ImHex\ImHexPortable.exe|single"
);
$menu = "";
// Iterate through the array
foreach ($entries as $item) {
$name = gettoken($item, 1, "|");
$exe = gettoken($item, 2, "|");
$mode = gettoken($item, 3, "|");
if (!exists($exe)) { continue; }
if ($mode == "single" && $numSel > 1) { continue; }
// Use <selitems> to pass multiple files to the executable
$cmd = "run " . quote($exe) . " <selitems>";
$menu .= $name . ";" . $cmd . ";" . $exe . "|";
}
if ($menu == "") { echo "No apps available."; }
// popupnested(menu, [x], [y], [width], [height], [heading], [separator], [item_separator])
$command = popupnested($menu, , , , , , "|", ";");
if ($command != '') {
load $command, , "s";
}
the script works but i receive an error\warning: Dubious syntax: "<xydrive>\Portables\~Viewers\notepad++\notepad++.exe" "D:\test1.txt" "D:\test2.txt"
Press continue and the command runs ok. If i disable "Script > Syntax Checking" the script runs without warnings..
Sorry my english!
Re: why this script don't work?
Posted: 14 Jan 2026 13:16
by highend
Use eval() to resolve the xy variable and fix the quoting?
@Don
Is it intended, that variables in arrays aren't resolved as long as they are used either natively or in double quotes?
Re: why this script don't work?
Posted: 14 Jan 2026 14:48
by admin
highend wrote: ↑14 Jan 2026 13:16
@Don
Is it intended, that variables in arrays aren't resolved as long as they are used either natively or in double quotes?
Not really. Fixed in next beta.
Re: why this script don't work?
Posted: 16 Jan 2026 18:23
by klownboy
I'm curious if you got the last version to work after Don made the v28.10.0308 beta change? I made some changes to the array values to suit me and modified the $cmd = "run ""$exe"" <selitems>"; line to get it to work (i.e., the menu displays and it runs the exe properly), but if syntax checking is ON (I have it set on normally) I receive, Dubious syntax: "D:\Tools\AkelPad\AkelPad.exe" "D:\Tools\XYplorer\Scripts\2FaVs.txt". Without syntax checking it runs through fine. Obviously my quoting is bad...highend are you out there?
Re: why this script don't work?
Posted: 16 Jan 2026 19:02
by highend
$cmd = "run lax(" . quote($exe) . " <selitems>" . ")";
Btw: The ";" separator shouldn't be used within the script, so better change it to <crlf>...
Re: why this script don't work?
Posted: 16 Jan 2026 19:58
by klownboy
Thanks highend, as I expected, it runs fine with syntax checking on. I don't know how many attempts I made at quoting with some using lax and quote but just didn't work with syntax checking on.