Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Manupulating record fields
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00107808
Message ID:
00107897
Vues:
29
>>I wish to find a way to do the following task. Please help.
>>
>>I have a record with 20 fields, from f_d1 to f_d20. How can I write a code so that I could replace the fields with a new data?
>>
>>Example, I want to replace f_d1 to fd20 with a today's date for f_d1 and an increament of one month for f_d2 and so on.
>>
>>How can I do that? Please show me with codes, thank you.
>
>for i=1 to 20
> lcFieldName = "f_d" + alltrim(str(i))
> replace &lcFieldName with Date() + i
>endfor

Nabil, your idea is correct, but it will increment each field by days instead of months. Try:
for i=1 to 20
   lcFieldName = "f_d" + alltrim(str(i))
   replace &lcFieldName with gomonth(Date(), i-1)
endfor
This will put today's date in f_d1, and increment each succeeding field by one month. The GoMonth() function helps cope with months with un-equal numbers of days, etc.

Barbara
Barbara Paltiel, Paltiel Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform