Re: Scripting Bugs
Posted: 04 Mar 2016 16:43
Yep, fine new scripting bug!
Fix comes.
Fix comes.
Forum for XYplorer Users and Developers
https://www.xyplorer.com/xyfc/
That's it:admin wrote:Yep, fine new scripting bug!![]()
Fix comes.
This error is too complex for my modest homegrown parser. A minimum of user smartness is needed in scripting.PeterH wrote: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.
I think it is a bug. Well, I fixed it, so that kind of makes it a bug by reverse logic.TheQwerty wrote: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.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.
admin wrote:This error is too complex for my modest homegrown parser. A minimum of user smartness is needed in scripting.
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";Apparently only double-quotes.TheQwerty wrote:an odd number of quotes:
Indeed and this shows my description of the bug is incorrect.PeterH wrote:Interesting to change the 1st line to
$test = 'a|b"c|d|e"|f|g';![]()
For sure "foreach" should handle double-quotes as any other character.
(Like it does with single quotes, as Sammay said.)
PeterH wrote:I think special handling of double-quotes *would* only make sense, if a pair of them *could* include separators.
Exactly. There shouldn't be absolutely any difference at all between single and double quotes, outside of (1) variable interpretation, and (2) escaped internal quoting, both cases just require looking at which quotes are enclosing the string.any double-quote should just be handled as any other character. (As is for single quotes.) And as such there's no difference if it's only one ore a pair of them.
If what you're trying to get at is a way to escape the separator then I don't think quoting is a good method.PeterH wrote:I think special handling of double-quotes *would* only make sense, if a pair of them *could* include separators.
I had the same feeling but the only issue coming to mind was klownboy's quoted-separators become gotos issue which was apparently introduced after 16.40. This bug however appears in that version as well so it's unlikely to be related. (Plus multiple people can recreate this one.SammaySarkar wrote:There's something fishy about double-quotes handling. IIRC, there was another scrpting issue with double quotes very recently.
So it seems we all think that a double-quote should be handled here as any other character.PeterH wrote:But I don't think this would make sense.
Thanks. Same bug in File | File Special | Swap Names.SammaySarkar wrote:SC swapnames generates a success status message even if the operation failed (say, the items were UAC protected).