Strange problem with <crlf> in a script

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
MBaas
Posts: 710
Joined: 15 Feb 2016 21:08

Strange problem with <crlf> in a script

Post by MBaas »

I've made some nice progress on a little scripting-project, but now I've hit a brick wall. Hopefully the following description will be good enough to understand the problem.

The idea is to build a menu for popupnested. To a large extent that works nicely, the remaining problem I need to deal with is this:
31-01-_2021_12-19-26.png
These menu-items are taken from the User-menu and they icons do work there (the menu shown contains the 2nd half of "Open With":
31-01-_2021_12-24-07.png
The problem with missing icon is caused by a blank line in the menu that is passed to popupnested. The relevant section of the menu (copied from the variable) looks like this:

Code: Select all

&Open with...
  Beyond Compare|load "<xyscripts>\bcompare.xys";
  ---
  #176
  RepoLauncher.cmd|#1403|%iconlib%\git.ico
  VS Code|#1402|%iconlib%\vscode.ico
  UEStudio|#1400|%iconlib%\uestudio.ico

Rename

Ok, I hear you: "Dummy, just get rid of that line!"
Well, that's my problem. Right before the call to pupupnested, I thought I did that:

Code: Select all

        $Menu = formatlist($Menu,"e",<crlf>);   // remove empty lines
That is followed by text $Menu and the call to popupnested. The piece above was taken right from that text-display which surprisingly does not show that empty line:
31-01-_2021_12-32-41.png
Yet, if I click the Copy-Btn, I get the empty line. I saved the menu to a file and verified that it contains 0D 0A 0D 0A (CRLF CRLF) at that position!

Questions:
  • why doesn't formatlist clean out that empty line?
  • is this behaviour know to be a problem and is there a workaround?
  • the menu is then displayed using

    Code: Select all

    $sel = popupnested($Menu, 6:=<crlf>, 7:="|");
    - isn't it somewhat fishy that the empty next line would affect the display of the icon of a menuitem?
To see the attached files, you need to log into the forum.
____________________________________________________________________________________
Happy user. Screen scaling 100% and W11Pro [Version 10.0.26200.7922], XY 28.30.14000 * F² * LinkTree

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

Re: Strange problem with <crlf> in a script

Post by highend »

Before using popupnested():
writefile() the $Menu and attach it here
hexdump() it and show the screenshot
One of my scripts helped you out? Please donate via Paypal

MBaas
Posts: 710
Joined: 15 Feb 2016 21:08

Re: Strange problem with <crlf> in a script

Post by MBaas »

Dang - looking at the hex dump I noticed a 0D 0A 0D-sequence that I didn't spot before (or that I introduced when I played more with the code). I better get rid of that spurious 0D before my next post :oops:
____________________________________________________________________________________
Happy user. Screen scaling 100% and W11Pro [Version 10.0.26200.7922], XY 28.30.14000 * F² * LinkTree

MBaas
Posts: 710
Joined: 15 Feb 2016 21:08

Re: Strange problem with <crlf> in a script

Post by MBaas »

Oh well - that was some hairy string-fiddling, but I think I got it now :whistle: Thanks for listing - it helped to talk about it! :wink:
____________________________________________________________________________________
Happy user. Screen scaling 100% and W11Pro [Version 10.0.26200.7922], XY 28.30.14000 * F² * LinkTree

Post Reply