Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Short-Circuiting with Logical Operators
Message
De
28/10/2014 03:46:28
 
 
À
28/10/2014 03:36:09
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows Server 2003
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01609995
Message ID:
01610001
Vues:
51
>Procedure call:
>
>DO blabla
>
>
>function call
>
>blabla()
>
>
>if you define
>
>
>PROCEDURE blabla
>
>or
>
>FUNCTION blabla
>
>
>does not mean a bit
>
I know that - but that was only used to show the short-circuiting

And both functions return true in this case


>
>>>This is way a function should just do it's job (return a value) rather then having side effects like
>>>
>>>change of Parameters
>>>Output
>>>....
>>>
>>>VFP's style to mix up function and procedure (determination by the way to call instead of definition) makes this very unclear.
>>
>>
>>??
>>
>>>Lutz
>>>
>>>>In one of my apps I just found and fixed a subtle edge-case bug caused by short-circuiting of logical operators. With my coding style I'm not usually vulnerable to it so it was interesting to be reminded of this feature of VFP.
>>>>
>>>>LOCAL ;
>>>>	llFlag
>>>>
>>>>llFlag = .F.
>>>>
>>>>CLEAR
>>>>
>>>>IF MyUDF( "First Argument" ) AND llFlag
>>>>
>>>>ENDIF
>>>>
>>>>IF llFlag AND MyUDF( "Second Argument" )
>>>>
>>>>ENDIF
>>>>
>>>>RETURN
>>>>
>>>>FUNCTION MyUDF ( tcArgumentPosition AS String )
>>>>
>>>>?"MyUDF( ) called when it is " + tcArgumentPosition
>>>>
>>>>ENDFUNC
>>>>
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform