Page 1 of 1

Strange problem with <crlf> in a script

Posted: 31 Jan 2021 12:44
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?

Re: Strange problem with <crlf> in a script

Posted: 31 Jan 2021 13:52
by highend
Before using popupnested():
writefile() the $Menu and attach it here
hexdump() it and show the screenshot

Re: Strange problem with <crlf> in a script

Posted: 31 Jan 2021 15:15
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:

Re: Strange problem with <crlf> in a script

Posted: 31 Jan 2021 16:37
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: