Page 36 of 41

Re: Scripting Bugs

Posted: 05 Apr 2016 11:07
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.

Re: Scripting Bugs

Posted: 06 Apr 2016 14:36
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]";

Re: Scripting Bugs

Posted: 06 Apr 2016 14:55
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.

Re: Scripting Bugs

Posted: 06 Apr 2016 16:09
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!

Re: Scripting Bugs

Posted: 06 Apr 2016 16:21
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.

Re: Scripting Bugs

Posted: 06 Apr 2016 16:30
by PeterH
:appl: :D :tup:

Re: Scripting Bugs

Posted: 12 Apr 2016 08:33
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*/ ;

Re: Scripting Bugs

Posted: 12 Apr 2016 08:51
by admin
Thanks, fix comes!

Re: Scripting Bugs

Posted: 12 Apr 2016 09:07
by bdeshi
:tup: plus "If omitted a list of sections is returned." in it's file param description.

Re: Scripting Bugs

Posted: 12 Apr 2016 09:10
by admin
GOSH. Lol! :tup:

Re: Scripting Bugs

Posted: 19 Apr 2016 00:16
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"

Re: Scripting Bugs

Posted: 19 Apr 2016 10:54
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!

Re: Scripting Bugs

Posted: 19 Apr 2016 12:13
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.

Re: Scripting Bugs

Posted: 19 Apr 2016 12:16
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"

Re: Scripting Bugs

Posted: 19 Apr 2016 12:36
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.