Get Dual Pane mode?

Discuss and share scripts and script files...
admin
Site Admin
Posts: 66249
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Get Dual Pane mode?

Post by admin »

TheQwerty wrote:
admin wrote:
TheQwerty wrote:If only we had a not-operator then you could make it:

Code: Select all

if (! get('#800')) {
  #800;
}
If only... :cry: :wink:
Try next version. :wink: (No time to document it...)

PS: All this should work in 9.70.0005... looks like I got it. :D
I had expected that this would also work:

Code: Select all

$a = 'a';
  if (! "$a" Like "") {
    echo 'hi';
  }
Not a deal breaker since it seems to work with parens:

Code: Select all

$a = 'a';
  if (! ("$a" Like "")) {
    echo 'hi';
  }
Yes, parens are necessary since the NOT operator is pretty much at the end of the precedence chain.

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

Re: Get Dual Pane mode?

Post by TheQwerty »

admin wrote:Yes, parens are necessary since the NOT operator is pretty much at the end of the precedence chain.
Erm, I don't like that parens are required here but I'll get over it.

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:
The operator precedence is (*,/) > (+,-) meaning that * and / are of equal weight, and + and - are of equal weight.
Take a look at the nice tables other languages have: Python, C#, Java, C++, PHP

Maybe even note where not appears in their orders. ;)

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

Re: Get Dual Pane mode?

Post by admin »

TheQwerty wrote:
admin wrote:Yes, parens are necessary since the NOT operator is pretty much at the end of the precedence chain.
Erm, I don't like that parens are required here but I'll get over it.
Looks totally normal to me. I'm not aware of a language where this would be different.

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

Re: Get Dual Pane mode?

Post by TheQwerty »

admin wrote:Looks totally normal to me. I'm not aware of a language where this would be different.
I feel the required parens are just wasteful and make the code more difficult to read.. it's more likely that when someone uses:

Code: Select all

if (not "$a" Like '') {...}
that they want "if $a is not empty", rather than "if $a-not'd is empty".

The only reason I've ever wanted a not operator is for avoiding having to switch between:

Code: Select all

if ("$a" Like '') {} else { ... }
and

Code: Select all

if (Compare("$a", '')) { ... }
I have never ever wanted to test $a-not'd against anything.


In the very least could you at least add something like

Code: Select all

if ("$a" not Like '') { ... }
or

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?

Post by PeterH »

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. :cry:
(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 :oops: ) 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. :oops:

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

Re: Get Dual Pane mode?

Post by admin »

Tip: All Scripting related stuff in the Help is under "Scripting" in the Index.

Yes, I will add something on precedence to the Help.

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

Re: Get Dual Pane mode?

Post by PeterH »

admin wrote:Tip: All Scripting related stuff in the Help is under "Scripting" in the Index.
Hey - thanks for the tip! I never noticed the grouping of search-words below Scripting in the index. :oops: This at least helps a bit...

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.

Post Reply