Page 34 of 41

Re: Scripting Bugs

Posted: 24 Nov 2015 09:49
by admin
Indeed, very good! This bug is there since the "e" flag was added in v15.70.0118 - 2015-09-14 14:51. Thanks! Fix coming.

Re: Scripting Bugs

Posted: 16 Feb 2016 19:03
by bdeshi
Did ::delete 1,1, <curitem>; on drives view, got Error 9. Probably less alarming to issue the "Not allowed here and now" msg. :kidding:

Code: Select all

Error 9

Error:  	9 (0x00000009)
Desc:   	Subscript out of range
Dll:    	0
Proc:   	RefreshAfterShop

Source: 	XYplorer
XY ver: 	XYplorer 16.20.0203
OS:     	Windows 10, 64-bit
Locale: 	1033
ANSI:   	1252
ACP:    	1252  (ANSI - Latin I)
DBCS:   	No
DPI:    	96 (100%)

Date:   	2016-02-17 00:01:02
[/size]

Re: Scripting Bugs

Posted: 17 Feb 2016 09:33
by admin
LOL. Thanks, good find. I will not issue any message. Just quit the attempt silently.

Re: Scripting Bugs

Posted: 18 Feb 2016 15:59
by PeterH
ScriptStrictSyntay=1 :arrow: a small problem

I always use ScriptStrictSyntax=1 (Usually very helpful :-) )

Now, defining a User Defined Function, I forgot the starting {
=> no error shown.
But: the terminating } of an If inside of this function physically terminated the whole function body.

Like (just to demonstrate - $p may be 0, positive or other :biggrin: ):

Code: Select all

Function Func($p)   // here the missing {
 If ($p == 0) {
   text "hallo";
 }
// the previous } cuts off all of the following text!
// script works just up to this line.
 ElseIf ($p > 0) {
   text "Never executed...";
 }
 Else {
   text 'Else';
 }

 Text 'Never reached, too';
I'd say:
either the function should work without the embedding {} - as a normal script does,
or the missing { should be reported.

Re: Scripting Bugs

Posted: 21 Feb 2016 15:23
by Filehero

Code: Select all

"Borken HEREDOCs"

  $here = <<<MENU
  if (<get "shift"> == 2) {

MENU;

  msg($here);
<get "shift"> shouldn't be evaluated, shouldn't it?

FH

Re: Scripting Bugs

Posted: 21 Feb 2016 15:33
by admin
Help:
Within the Heredoc section:

(3) Line feeds, empty lines, and all kinds of comments survive.

(4) Lines are not trimmed (leading and trailing spaces are preserved).

(5) Quoting is handled automatically (no need to add outer quotes or to double inner quotes).

(6) Variables are resolved.

Re: Scripting Bugs

Posted: 21 Feb 2016 15:49
by Filehero
admin wrote:Help:
Within the Heredoc section:
(6) Variables are resolved.
Arghh, sort of "forgot" it's a variable. :oops:

Sometimes I wish I could escape some chars like "$" or "<" to avoid resolving of individual variable strings. Would make on-the-fly-code-generation much easier - at least a bit more elegant when there's need to combine some new SC code with values from surrounding scope (e.g. looping). Something like

Code: Select all

if (\\<get "shift"> == 2) {...
instead of

Code: Select all

$get = "<" . "get ""shift"">";
if ($get == 2) {...

Re: Scripting Bugs

Posted: 21 Feb 2016 16:53
by bdeshi
Sometimes I wish I could escape some chars like "$" or "<" to avoid resolving of individual variable strings.

Code: Select all

  $hello = "hello";

  $var   = '$hello';
  $code  = <<<#>>>
 step;
 $var = "goodbye";
 ECHO $var;#>>>;
  load $code,,'s';
 echo $hello;

Re: Scripting Bugs

Posted: 21 Feb 2016 16:59
by admin
Tip: Check Help for "Nowdoc"...

Re: Scripting Bugs

Posted: 21 Feb 2016 18:24
by Filehero
admin wrote:Tip: Check Help for "Nowdoc"...
But with Nowdocs nothing is ressolved, right?

@Sammay: that's another flavor of what can get quite hard to read sometimes.

Anyway, it's was rather a long sigh. And i finally got rid of those nasty warnings. :wink:

edit: some changes

Re: Scripting Bugs

Posted: 21 Feb 2016 18:48
by highend
But with Nowdocs nothing is ressolved, right?
Correct

Re: Scripting Bugs

Posted: 22 Feb 2016 17:02
by PeterH
PeterH wrote:ScriptStrictSyntay=1 :arrow: a small problem

I always use ScriptStrictSyntax=1 (Usually very helpful :-) )

Now, defining a User Defined Function, I forgot the starting {
=> no error shown.
But: the terminating } of an If inside of this function physically terminated the whole function body.

Like (just to demonstrate - $p may be 0, positive or other :biggrin: ):

Code: Select all

Function Func($p)   // here the missing {
 If ($p == 0) {
   text "hallo";
 }
// the previous } cuts off all of the following text!
// script works just up to this line.
 ElseIf ($p > 0) {
   text "Never executed...";
 }
 Else {
   text 'Else';
 }

 Text 'Never reached, too';
I'd say:
either the function should work without the embedding {} - as a normal script does,
or the missing { should be reported.
No :?:

Re: Scripting Bugs

Posted: 22 Feb 2016 18:16
by TheQwerty
Okay.. opinions on whether this is a bug or not:

Code: Select all

function test() {
  perm $value = rand(0,1000);
  echo "Test set value to $value";
}

test();echo "Script sees value of $value";
First execution main script does not find $value in scope. (Assuming you didn't have a $value PV which I just blew away for you. :twisted: )
On the second execution it will pick it up correctly.

In other words the calling script is not made aware of permanent variables created by functions.


This can be resolved by bringing the PV into scope before using it (before or after calling test() makes no difference) so it's no big deal, but may need pause for thought.

Re: Scripting Bugs

Posted: 22 Feb 2016 18:51
by admin
Both recent posts postponed to after 16.30 release.

Re: Scripting Bugs

Posted: 04 Mar 2016 00:20
by PeterH
A fine new scripting bug:
If a function returns a parameter variable BY REFERENCE, and the *passed* variable is a global, the variable is not set on return.
Example:

Code: Select all

// Test a function RETURNING a variable BY REFERENCE, where the passed var is a global

 Global $gvar; // if $gvar is Global, func doesn't return it!
   $gvar = 5;
   func($gvar, 3);
   text "5 + 3 = $gvar";

Function func(&$p1, $p2) { $p1 = $p1 + $p2; }
As shown, 5 + 3 = 5 is displayed, as $gvar is not set on return from func().
If you comment the Global stmt, 5 + 3 = 8 is correctly shown.