Scripting Bugs
Forum rules
READ THIS AND DO IT!!!
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%).
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.
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
READ THIS AND DO IT!!!
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%).
-
admin
- Site Admin
- Posts: 65351
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Scripting Bugs
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.
FAQ | XY News RSS | XY X
Re: Scripting Bugs
Did ::delete 1,1, <curitem>; on drives view, got Error 9. Probably less alarming to issue the "Not allowed here and now" msg.
[/size]
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
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ 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
LOL. Thanks, good find. I will not issue any message. Just quit the attempt silently.
FAQ | XY News RSS | XY X
-
PeterH
- Posts: 2826
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Scripting Bugs
ScriptStrictSyntay=1
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
):
I'd say:
either the function should work without the embedding {} - as a normal script does,
or the missing { should be reported.
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
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';either the function should work without the embedding {} - as a normal script does,
or the missing { should be reported.
Re: Scripting Bugs
Code: Select all
"Borken HEREDOCs"
$here = <<<MENU
if (<get "shift"> == 2) {
MENU;
msg($here);FH
-
admin
- Site Admin
- Posts: 65351
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Scripting Bugs
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.
FAQ | XY News RSS | XY X
Re: Scripting Bugs
Arghh, sort of "forgot" it's a variable.admin wrote:Help:Within the Heredoc section:
(6) Variables are resolved.
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) {...Code: Select all
$get = "<" . "get ""shift"">";
if ($get == 2) {...Re: Scripting Bugs
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 ]
[ this user is asleep ]
Re: Scripting Bugs
But with Nowdocs nothing is ressolved, right?admin wrote:Tip: Check Help for "Nowdoc"...
@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.
edit: some changes
Re: Scripting Bugs
CorrectBut with Nowdocs nothing is ressolved, right?
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
NoPeterH wrote:ScriptStrictSyntay=1a 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):
I'd say: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';
either the function should work without the embedding {} - as a normal script does,
or the missing { should be reported.
Re: Scripting Bugs
Okay.. opinions on whether this is a bug or not: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.
)
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.
Code: Select all
function test() {
perm $value = rand(0,1000);
echo "Test set value to $value";
}
test();echo "Script sees value of $value";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.
-
PeterH
- Posts: 2826
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Scripting Bugs
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:
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.
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; }If you comment the Global stmt, 5 + 3 = 8 is correctly shown.
XYplorer Beta Club