Scripting Bugs

Things you’d like to miss in the future...
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::bug: foreach aborts unexpectedly after handling a token containing an odd number of quotes:

Code: Select all

$test = 'a|b"c|d|e|f|g';
  $c = GetToken($test, 'Count', '|');
  $i = 0;
  foreach($line, $test) { $i++; }

  Echo "Iterated over $i lines.<crlf>Expected: $c";
Separator makes no difference - I ran into it parsing output from GetSectionList with its default CRLF.
Indeed, thanks! Fix coming...

FYI, any quotes within the ListOfTokens in a Foreach statement are (now) seen as normal characters. They have no special "quoting function". This was not 100% implemented before the fix.

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

Re: Scripting Bugs

Post by TheQwerty »

admin wrote:Indeed, thanks! Fix coming...

FYI, any quotes within the ListOfTokens in a Foreach statement are (now) seen as normal characters. They have no special "quoting function". This was not 100% implemented before the fix.
Foreach is much better now!

But, take a look at FormatList, it also seems to have a less than 100% quote handling implementation:

Code: Select all

$test = '|a||b"c||d|';

  $a = FormatList($test, 'e', '|');
  $an = GetToken($a, 'Count', '|');

  $e = Trim(RegexReplace($test, '\|\|+', '|'), '|', 'LR');
  $en = GetToken($e, 'Count', '|');

  Echo "Remove empties from: $test<crlf>Expected: $e  [$en tokens]<crlf>Actual: $a  [$an tokens]";

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

Re: Scripting Bugs

Post by PeterH »

A new one: :bug: in ReplaceList()

There's something I'd call a bug in ReplaceList(): if the searchlist contains only 1 element it's not found. If there are at least 2 elements it's OK.

Example:

Code: Select all

  $a = 'abcd123';
  $r = 'a';
  $s = 'a1';
  $y = ReplaceList($a, $r); // the 'a' is not found: no action
  $z = ReplaceList($a, $s); // 'a' and '1' are found and deleted
  Text "'$y', '$z'";
I don't think it's OK this way.
W7(x64) SP1 German
( +WXP SP3 )

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:Indeed, thanks! Fix coming...

FYI, any quotes within the ListOfTokens in a Foreach statement are (now) seen as normal characters. They have no special "quoting function". This was not 100% implemented before the fix.
Foreach is much better now!

But, take a look at FormatList, it also seems to have a less than 100% quote handling implementation:

Code: Select all

$test = '|a||b"c||d|';

  $a = FormatList($test, 'e', '|');
  $an = GetToken($a, 'Count', '|');

  $e = Trim(RegexReplace($test, '\|\|+', '|'), '|', 'LR');
  $en = GetToken($e, 'Count', '|');

  Echo "Remove empties from: $test<crlf>Expected: $e  [$en tokens]<crlf>Actual: $a  [$an tokens]";
Confirmed and fixed, thanks!

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

Re: Scripting Bugs

Post by admin »

PeterH wrote:A new one: :bug: in ReplaceList()

There's something I'd call a bug in ReplaceList(): if the searchlist contains only 1 element it's not found. If there are at least 2 elements it's OK.

Example:

Code: Select all

  $a = 'abcd123';
  $r = 'a';
  $s = 'a1';
  $y = ReplaceList($a, $r); // the 'a' is not found: no action
  $z = ReplaceList($a, $s); // 'a' and '1' are found and deleted
  Text "'$y', '$z'";
I don't think it's OK this way.
Indeed, good find! :tup: Fix comes.

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

Re: Scripting Bugs

Post by PeterH »

:appl: :D :tup:
W7(x64) SP1 German
( +WXP SP3 )

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Scripting Bugs

Post by bdeshi »

savethumb() pops "invalid parameter" error if heightbox param isn't provided.

Code: Select all

::savethumb(,,"100%") /*heightbox not given - error*/ ;  savethumb(,,,'100%') /*at least heightbox given - ok*/ ;
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

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

Re: Scripting Bugs

Post by admin »

Thanks, fix comes!

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Scripting Bugs

Post by bdeshi »

:tup: plus "If omitted a list of sections is returned." in it's file param description.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

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

Re: Scripting Bugs

Post by admin »

GOSH. Lol! :tup:

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

Re: Scripting Bugs

Post by PeterH »

...and a new one :whistle:

Code: Select all

 text substr("X2", 2, 1);  // correct: returns the 3rd character (from left) = ""
 text substr("X2", -2, 1); // correct: returns the 2nd char from right = "X"
 text substr("X2", -3, 1); // wrong: should return 3rd char from right = "", but returns "X"
W7(x64) SP1 German
( +WXP SP3 )

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

Re: Scripting Bugs

Post by admin »

Yep. That was actually done on purpose (it's like PHP works), but I agree it's unexpected and simply looks like a bug. I will fix it. Thanks!

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

Re: Scripting Bugs

Post by PeterH »

Thanks a lot for acceptance! :tup: :cup: :om:

Short explanation: I work on a number, like:

Code: Select all

 $nr = 12;   // a number
 $add = 0;   // init
// then, inside a loop on $i:
   $i = 3;   // neg. index (variable!)
   $dig = substr($nr, -$i, 1); // get a digit (looping right to left)
   $add = $add + $dig;  // add digit to a number: "" = 0
For + the "" is like 0, so this way it's very simple - else I would have to code quite a lot, just inside a loop.
W7(x64) SP1 German
( +WXP SP3 )

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

Re: Scripting Bugs

Post by admin »

Now it will work like this (looks a bit weird but is totally systematic):

Code: Select all

        text substr("X2", -3);     // "X2"
        text substr("X2", -3, -2); // ""
        text substr("X2", -3, -1); // "X"
        text substr("X2", -3, 0);  // ""
        text substr("X2", -3, 1);  // ""
        text substr("X2", -3, 2);  // "X"
        text substr("X2", -3, 3);  // "X2"
        text substr("X2", -3, 4);  // "X2"

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

Re: Scripting Bugs

Post by PeterH »

Looks good.

But:
substr("X2", -4, 1)
substr("X2", -4, 2)
substr("X2", -4, 3)
I'd expect 1 and 2 to return "", 3 -> "X".
For my use case 1 is extremly important.
W7(x64) SP1 German
( +WXP SP3 )

Post Reply