Re: Scripting Bugs
Posted: 24 Nov 2015 09:49
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.
Forum for XYplorer Users and Developers
https://www.xyplorer.com/xyfc/
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
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';Code: Select all
"Borken HEREDOCs"
$here = <<<MENU
if (<get "shift"> == 2) {
MENU;
msg($here);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.
Arghh, sort of "forgot" it's a variable.admin wrote:Help:Within the Heredoc section:
(6) Variables are resolved.
Code: Select all
if (\\<get "shift"> == 2) {...Code: Select all
$get = "<" . "get ""shift"">";
if ($get == 2) {...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;
But with Nowdocs nothing is ressolved, right?admin wrote:Tip: Check Help for "Nowdoc"...
CorrectBut with Nowdocs nothing is ressolved, right?
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.
Code: Select all
function test() {
perm $value = rand(0,1000);
echo "Test set value to $value";
}
test();echo "Script sees value of $value";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; }