SC popupmenu question

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Daniel0312
Posts: 154
Joined: 15 Feb 2016 10:48

SC popupmenu question

Post by Daniel0312 »

Code: Select all

  $TestString = "Value1<crlf>Value2";
  $menu = <<<MENU
  ::UPPER;copytext recase("$TestString")
  MENU;
  popupmenu($menu);
The above code works fine as long as there is no <crlf> in the string.
When there is one, it's seen as a break in the code line and interpreted accordingly.
Is there a way around it ?
Daniel
Windows7 SP1 x64 / XY latest stable

jupe
Posts: 2809
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: SC popupmenu question

Post by jupe »

Make sure the variable isn't resolved beforehand. eg.

Code: Select all

  $TestString = 'Value1<crlf>Value2';
  $menu = <<<MENU
  ::UPPER;copytext recase("$TestString")
  MENU;
  popupmenu($menu);

Daniel0312
Posts: 154
Joined: 15 Feb 2016 10:48

Re: SC popupmenu question

Post by Daniel0312 »

Thanks jupe, it works indeed in this case.
The problem is I want to use the clipboard as entry string, and insert this (simplified) code in an existing popupmenu.

Code: Select all

$menu = <<<MENU
Recase
 ::UPPER;copytext recase("<clipboard>", "upper");
 ::Invert;copytext recase("<clipboard>", "invert");
MENU;
$return = popupnested($menu, 6:=<crlf>, 7:=";");
I've been trying quite a lot of single and double quotes permutations... no joy.
Single-quoting <clipboard> doesn't seem to be an option.
Any idea (other than creating one sub for each "problem" item) ?
Daniel
Windows7 SP1 x64 / XY latest stable

highend
Posts: 13338
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: SC popupmenu question

Post by highend »

One way:

Code: Select all

    $menu = <<<MENU
Recase
 UPPER;recase_upper
 Invert;recase_invert
    MENU;
    $return = popupnested($menu, 6:=<crlf>, 7:=";");

    if ($return == "recase_upper") {
        copytext recase(<clipboard>, "upper");
    } elseif ($return == "recase_invert") {
        copytext recase(<clipboard>, "invert");
    }
All other entries that don't contain <crlf> can still be done in the old way
One of my scripts helped you out? Please donate via Paypal

Daniel0312
Posts: 154
Joined: 15 Feb 2016 10:48

Re: SC popupmenu question

Post by Daniel0312 »

It'a a good way, gives me things to think about :)
It seems the only way is to get the <clipboard> and it's <crlf> out of the menu string.
Thanks highend.
Daniel
Windows7 SP1 x64 / XY latest stable

jupe
Posts: 2809
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: SC popupmenu question

Post by jupe »

There are multiple ways to achieve what you want, here is another one if you are still interested.

Code: Select all

  function cb() { return <clp>; }
  $menu = <<<MENU
  Recase
    ::UPPER; copytext recase(cb(), "upper");
    ::Invert;copytext recase(cb(), "invert");
  MENU;
  $return = popupnested($menu, 6:=<crlf>, 7:=";");

Daniel0312
Posts: 154
Joined: 15 Feb 2016 10:48

Re: SC popupmenu question

Post by Daniel0312 »

I'm always interested in learning new things.
And I really like this one, elegant.
Many thanks jupe.
Daniel
Windows7 SP1 x64 / XY latest stable

Post Reply