Scripting Bugs

Things you’d like to miss in the future...
zer0
Posts: 2673
Joined: 19 Jan 2009 20:11

Re: Scripting Bugs

Post by zer0 »

admin wrote:Without any testing I would say simply append the delimiter manually if you really need it at the end:

Code: Select all

$filelist = getinfo('SelectedItemsPathNames', '|') . '|';
Yep, that works, thanks! :D

P.S. Would be nice for XY to identify such pitfalls and alert the user :wink:
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting Bugs

Post by admin »

zer0 wrote:
admin wrote:Without any testing I would say simply append the delimiter manually if you really need it at the end:

Code: Select all

$filelist = getinfo('SelectedItemsPathNames', '|') . '|';
Yep, that works, thanks! :D

P.S. Would be nice for XY to identify such pitfalls and alert the user :wink:
XY != God.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Scripting Bugs

Post by TheQwerty »

Just a suggestion: You'd probably be better off using GetToken() instead of substr and strpos.

zer0
Posts: 2673
Joined: 19 Jan 2009 20:11

Re: Scripting Bugs

Post by zer0 »

admin wrote:XY != God.
Agreed. But not all people who use scripts are experts at scripting. I was able to narrow down the cause to a particular change of a specific beta release. Proactive action is not only smart, but also saves time which is in my case means money.
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Scripting Bugs

Post by PeterH »

zer0 wrote:
admin wrote:XY != God.
Agreed. But not all people who use scripts are experts at scripting. I was able to narrow down the cause to a particular change of a specific beta release. Proactive action is not only smart, but also saves time which is in my case means money.
You're a kind of right here...
...but what would you expect? Don could have added:

Code: Select all

If your script depends on the now deleted trailing delimiter, you have to change it accordingly
I think most people would say: of course you must!

He also could have added:

Code: Select all

If you wrongly misused the token separators including the last one as a kind of end-of-token-identifiers, you either have to add a separator to the end of the string, or change the logic to interpret the string as character-separated tokens.
For this version he would be in need of some God-like skills, I think..

So I'm afraid that such situations could only be avoided, if Don would never change anything regarding scripting. And I think we would not like that...

zer0
Posts: 2673
Joined: 19 Jan 2009 20:11

Re: Scripting Bugs

Post by zer0 »

As of late, I have to do renaming that involves removing a string that ends with a dot and appears at either beginning or end of a file name. I would use this command to accomplish the desired:

Code: Select all

rename s, "text.to.remove./";
However, if that string is at the end of the base name, XYplorer refuses to remove it. My suspicion is that this is because it thinks that removing that dot would alter the extension and since there is no "/e" switch present, it does not proceed.

Here comes the fun part...if that string appears at the end, it is always preceded by a dot. So, in the context of the above example, it would be ".text.remove.<ext>". Renaming manually works as the dot just before <ext> is replaced by the dot before the removed string. Thus, XYplorer baulking when a string is at the end is unwanted behaviour -- a file's extension isn't modified in any way. Can some smartness please be injected in this situation? :wink:
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Scripting Bugs

Post by TheQwerty »

zer0 wrote:

Code: Select all

rename s, "text.to.remove./";
However, if that string is at the end of the base name, XYplorer refuses to remove it. My suspicion is that this is because it thinks that removing that dot would alter the extension and since there is no "/e" switch present, it does not proceed.
Not arguing against teaching Search & Replace some new tricks, but could you not use regex here instead?

Code: Select all

rename r, "text\.to\.remove\. > ";

zer0
Posts: 2673
Joined: 19 Jan 2009 20:11

Re: Scripting Bugs

Post by zer0 »

TheQwerty wrote:Not arguing against teaching Search & Replace some new tricks, but could you not use regex here instead?

Code: Select all

rename r, "text\.to\.remove\. > ";
I can, but not being very proficient in RegEx meant that it wasn't the first renaming method that I went for. Your method works, but that trick should definitely be taught to S&R.
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

zer0
Posts: 2673
Joined: 19 Jan 2009 20:11

Re: Scripting Bugs

Post by zer0 »

Running html() with the following code causes XYplorer to stop responding

Code: Select all

<html><head>
    <style type="text/css">
    #a {
            margin:0 10px 10px;
    }
    #b {
            width:100%;
    }
    </style>
    <title>Makes XYplorer non-responsive</title>
    </head>
    <body>
    <table><tr><td>
    <div id="a">
    <form id="b">
    <input type="text" name="test"/>
    </div>
    </td><td width="1"></td></tr></table>
    </body></html>
Technically, it's not a problem with XYplorer, but IE. That said, since we can't help but use IE's engine, there should be some safety nets.
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting Bugs

Post by admin »

zer0 wrote:Running html() with the following code causes XYplorer to stop responding

Code: Select all

<html><head>
    <style type="text/css">
    #a {
            margin:0 10px 10px;
    }
    #b {
            width:100%;
    }
    </style>
    <title>Makes XYplorer non-responsive</title>
    </head>
    <body>
    <table><tr><td>
    <div id="a">
    <form id="b">
    <input type="text" name="test"/>
    </div>
    </td><td width="1"></td></tr></table>
    </body></html>
Technically, it's not a problem with XYplorer, but IE. That said, since we can't help but use IE's engine, there should be some safety nets.
Problem confirmed, but since the conditions for problematic HTML code are not known there is no way to provide a safety net.

zer0
Posts: 2673
Joined: 19 Jan 2009 20:11

Re: Scripting Bugs

Post by zer0 »

admin wrote:Problem confirmed, but since the conditions for problematic HTML code are not known there is no way to provide a safety net.
I've run it through the W3C Validator, played around some more and I believe this is the error that validator flagged that is the cause:
required attribute "ACTION" not specified

<form id="b">

The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.
Changing that id from "b" to "a" -- in line with <div> tag's name above -- makes the page load fine.
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Scripting Bugs

Post by TheQwerty »

Seems giving Report() an item list causes it to ignore the user-defined column formats.

Looks like it's been there since v9.40 so I'm guessing it goes all the way back to when Report was blessed with ItemList support.

Code: Select all

"Report Column Format Discrepency"
  Sel 1;
  $r1 = Report("{Created}  {Size}", "<focitem>");
  $r2 = Report("{Created}  {Size}", 1);
  Echo("F: $r1<crlf>S: $r2");

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting Bugs

Post by admin »

TheQwerty wrote:Seems giving Report() an item list causes it to ignore the user-defined column formats.

Looks like it's been there since v9.40 so I'm guessing it goes all the way back to when Report was blessed with ItemList support.

Code: Select all

"Report Column Format Discrepency"
  Sel 1;
  $r1 = Report("{Created}  {Size}", "<focitem>");
  $r2 = Report("{Created}  {Size}", 1);
  Echo("F: $r1<crlf>S: $r2");
That's on purpose. Giving a source list disconnects the report from the current list and it's formatting.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Scripting Bugs

Post by TheQwerty »

admin wrote:That's on purpose. Giving a source list disconnects the report from the current list and it's formatting.
Errr why? Why wouldn't I want the formatting here?

If I didn't want the formatting I would have included the desired formatting in the template, but I didn't because I want the same formatting as the column.

This means if a user wanted to compare the data from the focused item with the rest of the items they now have to jump through hoops; especially if they need to then use this data in SelFilter which expects the filter pattern to be in the exact same format as the column.

Unfortunately "{Created List}" doesn't work either, and in this case that would be more of a pain since I'm getting the column/template name from a Get("Sort") in the first place.


I really don't understand why I'd want to ignore the current list formatting just because I'm using a source list?

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Scripting Bugs

Post by admin »

TheQwerty wrote:
admin wrote:That's on purpose. Giving a source list disconnects the report from the current list and it's formatting.
Errr why? Why wouldn't I want the formatting here?

If I didn't want the formatting I would have included the desired formatting in the template, but I didn't because I want the same formatting as the column.

This means if a user wanted to compare the data from the focused item with the rest of the items they now have to jump through hoops; especially if they need to then use this data in SelFilter which expects the filter pattern to be in the exact same format as the column.

Unfortunately "{Created List}" doesn't work either, and in this case that would be more of a pain since I'm getting the column/template name from a Get("Sort") in the first place.


I really don't understand why I'd want to ignore the current list formatting just because I'm using a source list?
Can't really give a good reply now. The reporting code is quite complex and I did not look at it for more than a year. No idea how many users are using these functions but yours is the first complaint. From first impression I agree with you and wonder why it is as it is. But I would have to look very deep to make a good decision. No space for this in my schedule right now.

Post Reply