Scripting Bugs

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
admin
Site Admin
Posts: 65351
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Scripting Bugs

Post 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.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Scripting Bugs

Post 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]
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

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

Re: Scripting Bugs

Post by admin »

LOL. Thanks, good find. I will not issue any message. Just quit the attempt silently.

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Scripting Bugs

Post 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.

Filehero
Posts: 2721
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Scripting Bugs

Post 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

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

Re: Scripting Bugs

Post 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.

Filehero
Posts: 2721
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Scripting Bugs

Post 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) {...

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Scripting Bugs

Post 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;
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

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

Re: Scripting Bugs

Post by admin »

Tip: Check Help for "Nowdoc"...

Filehero
Posts: 2721
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Scripting Bugs

Post 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

highend
Posts: 14662
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Scripting Bugs

Post by highend »

But with Nowdocs nothing is ressolved, right?
Correct
One of my scripts helped you out? Please donate via Paypal

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Scripting Bugs

Post 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 :?:

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

Re: Scripting Bugs

Post 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.

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

Re: Scripting Bugs

Post by admin »

Both recent posts postponed to after 16.30 release.

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Scripting Bugs

Post 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.

Post Reply