Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Manupulating record fields
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00107808
Message ID:
00107897
Views:
30
>>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform