Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Evaluate
Message
De
29/06/2003 09:27:45
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
29/06/2003 07:56:09
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00805082
Message ID:
00805090
Vues:
31
>Please be more specific:
>What is this 'lcaname','loref'.
>Can you give me example from the life?

Andy's example assumes several objects on a form, and a property that has the object name.

The objects might be a group of TextBoxes, for instance, which you may want to manipulate in a loop.

Here is an example which you can easily reproduce. Place three text-boxes on a form, leaving the default names (Text1, Text2, Text3). Note: for a production system, it is recommended to give more meaningful names - leave the names for this sample only.

Add a CommandButton to the form. In its Click() event, place the following code:
for i = 1 to 3
	loTextBox = evaluate("ThisForm.Text" + trans(i))
	loTextBox.FontBold = .T.
next
This will make the text in the three TextBoxes bold.

Used this way, evaluate() can often simplify programming.


A quite different use of evaluate() is to calculate formulas typed by a user:
x = "1+2*3"
? evaluate(x) && shows the calculated result: 7
This is somewhat risky, since the user can also use this to execute any procedure of your system.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform