Yes, parens are necessary since the NOT operator is pretty much at the end of the precedence chain.TheQwerty wrote:I had expected that this would also work:admin wrote:Try next version.TheQwerty wrote:If only we had a not-operator then you could make it:If only...Code: Select all
if (! get('#800')) { #800; }![]()
(No time to document it...)
PS: All this should work in 9.70.0005... looks like I got it.
Not a deal breaker since it seems to work with parens:Code: Select all
$a = 'a'; if (! "$a" Like "") { echo 'hi'; }Code: Select all
$a = 'a'; if (! ("$a" Like "")) { echo 'hi'; }
Get Dual Pane mode?
-
admin
- Site Admin
- Posts: 66254
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Get Dual Pane mode?
FAQ | XY News RSS | XY X
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: Get Dual Pane mode?
Erm, I don't like that parens are required here but I'll get over it.admin wrote:Yes, parens are necessary since the NOT operator is pretty much at the end of the precedence chain.
However, I think you must add a section to the Scripting help documenting the full precedence of Math, Comparison, and Boolean operators to make this clear.
And I'd try to format it better than this extremely confusing way which requires a couple of reads:
Take a look at the nice tables other languages have: Python, C#, Java, C++, PHPThe operator precedence is (*,/) > (+,-) meaning that * and / are of equal weight, and + and - are of equal weight.
Maybe even note where not appears in their orders.
-
admin
- Site Admin
- Posts: 66254
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Get Dual Pane mode?
Looks totally normal to me. I'm not aware of a language where this would be different.TheQwerty wrote:Erm, I don't like that parens are required here but I'll get over it.admin wrote:Yes, parens are necessary since the NOT operator is pretty much at the end of the precedence chain.
FAQ | XY News RSS | XY X
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: Get Dual Pane mode?
I feel the required parens are just wasteful and make the code more difficult to read.. it's more likely that when someone uses:admin wrote:Looks totally normal to me. I'm not aware of a language where this would be different.
Code: Select all
if (not "$a" Like '') {...}The only reason I've ever wanted a not operator is for avoiding having to switch between:
Code: Select all
if ("$a" Like '') {} else { ... }Code: Select all
if (Compare("$a", '')) { ... }In the very least could you at least add something like
Code: Select all
if ("$a" not Like '') { ... }Code: Select all
if ("$a" Unlike '') { ... }-
PeterH
- Posts: 2827
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Get Dual Pane mode?
I'm not sure TheQwerty's reasons (like "I prefer ...") are very good -
but thinking about that I looked for operator precedence in XY - and found nothing.
(PS later found it: see below!)
Then I tried to look into the examples referenced by TheQwerty. Only half a success - they don't know a "like".
My solution: "like" does a kind of compare - it could by like < or ==. In this case ! ("not") seems to be *higher* in precedence? That is
! a == b would mean (! a) == b
Or do I read it wrong?
OK - you (Don) *could* *define* "like" much higher in precedence...
By the way: I had several problems in XY-documentation!
- I tried to find "like" via index and via find - no chance.
- Same for "if".
Hey - now I found "precedence"! (This *can* be searched
) But it only defines *, /, + and -, relating only to math?
*Wrong*
there is also another chapter with precedence for Boolean Operators!?
OK - what *should* be? Precedences are *all* related - it must be defined what's the meaning of
if ($a > $b + $c / 3 or ! $d like $e)
So I'm afraid there must be one single chapter like "Precedence of operators" for *all* operators - and the chapters for math and boolean should refer to this central point.
And as the very last thing to say: I myself always mix up precedences, and so I prefer excessive use of parentheses.
but thinking about that I looked for operator precedence in XY - and found nothing.
(PS later found it: see below!)
Then I tried to look into the examples referenced by TheQwerty. Only half a success - they don't know a "like".
My solution: "like" does a kind of compare - it could by like < or ==. In this case ! ("not") seems to be *higher* in precedence? That is
! a == b would mean (! a) == b
Or do I read it wrong?
OK - you (Don) *could* *define* "like" much higher in precedence...
By the way: I had several problems in XY-documentation!
- I tried to find "like" via index and via find - no chance.
- Same for "if".
Hey - now I found "precedence"! (This *can* be searched
*Wrong*
OK - what *should* be? Precedences are *all* related - it must be defined what's the meaning of
if ($a > $b + $c / 3 or ! $d like $e)
So I'm afraid there must be one single chapter like "Precedence of operators" for *all* operators - and the chapters for math and boolean should refer to this central point.
And as the very last thing to say: I myself always mix up precedences, and so I prefer excessive use of parentheses.
-
admin
- Site Admin
- Posts: 66254
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Get Dual Pane mode?
Tip: All Scripting related stuff in the Help is under "Scripting" in the Index.
Yes, I will add something on precedence to the Help.
Yes, I will add something on precedence to the Help.
FAQ | XY News RSS | XY X
-
PeterH
- Posts: 2827
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Get Dual Pane mode?
Hey - thanks for the tip! I never noticed the grouping of search-words below Scripting in the index.admin wrote:Tip: All Scripting related stuff in the Help is under "Scripting" in the Index.
But I think the scripting-topic is so long, in between the time, that it also should be divided into (sub-)topics in the Contents (German: "Inhalt"). I don't think it's sufficient just to have this very big Scripting-chapter in Advanced Topics. You have to scroll through all that chapter (about 20 pages), just to find a heading like "General Command Syntax", "Step Mode: ...", "Comments", "If/ElseIf/Else Blocks" or whatever.
XYplorer Beta Club