Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trivial question re return value and ()
Message
De
19/05/2016 10:25:13
 
 
À
19/05/2016 08:10:20
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
Windows Server 2012
Database:
Visual FoxPro
Application:
Desktop
Virtual environment:
VMWare
Divers
Thread ID:
01636581
Message ID:
01636622
Vues:
68
>>it seem to me that making a variable between () evaluate this expression and return the evaluated expression.
>>Whenever possible, using EVALUATE( ) or a name expression to replace macro substitution using the & Command.
>> EVALUATE and name expressions execute faster than macro substitution.
>>
>>usefull,Merci madame !
>
>RETURN always evaluates the expression that follows:
>
>
>RETURN m.x + m.y
>
>
>is no different than
>
>
>RETURN (m.x + m.y)
>
>
>As Mike said, the only time parentheses change what happens is when VFP expects a name. Then, the contents of the parentheses are treated as a name:
>
>
>USE Table
>
>
>tries to open a table named Table.
>
>
>USE (Table)
>
>
>tries to open a table whose name is contained in Table.
>
>Tamar

Just to add a bit more: the use of parentheses is just a way to tell VFP "treat this as an expression and not as a name". Most of the times when VFP expects a name, the name can be replaced by an expression, whether surrounded by parentheses or not, as long as there is no possible ambiguity; in some occasions, though, the parentheses is the only way for getting a expression through - as is the case of the REPLACE command:
LOCAL lcTable AS String
LOCAL lcField AS String

m.lcTable = ADDBS(SYS(2023)) + "tst" + SYS(2015)
m.lcField = "cField"

CREATE TABLE TRANSFORM(m.lcTable) ((m.lcField) C(1))
APPEND BLANK
REPLACE (m.lcField) WITH "@"
USE

USE "" + m.lcTable

BROWSE FOR cField = "@"

USE

ERASE m.lcTable + ".dbf"
----------------------------------
António Tavares Lopes
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform