Autore Topic: Usare AND ed OR nello stesso test logico  (Letto 343 volte)

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.316
  • Ne mors quidem nos iunget
    • Mostra profilo
Usare AND ed OR nello stesso test logico
« il: 06 Ottobre 2014, 01:25:28 »
Vi riporto questa discussione:


" Why is it not allowed to use AND and OR in the same logical test?

Jørn
"


" It is allowed and works:

  $ gbx3 -e "(False And Not False) Or (False Or Not False)"
  True

Maybe you refer to the AND IF and OR IF keywords in an IF statement?

Regards,
Tobi
"


" Aha, yes you're right :) Removing an extra IF that had sneaked in was
the solution.

Jørn
"


" The extra "if" enables short-circuiting
http://en.wikipedia.org/wiki/Short-circuit_evaluation
and thus it is very useful in some cases.

Example, you can write "if then" structures like this:

Codice: gambas [Seleziona]
If hObject <> Null And If hObject.SomeProperty = True Then


Without the extra "if" this would fail, if the hObject would be null.

Jussi
"
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »