Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field Names

Status
Not open for further replies.

icemiller

Programmer
Joined
May 22, 2001
Messages
4
Location
PH
how can i access the field names of a certain database file using arrays? for example. i have 10 fields, and i want to place data on each field.

e.g.
instead of:
replace fieldname1 with data
replace fieldname2 with data
replace fieldname3 with data
replace fieldname4 with data
...
replace fieldname10 with data

i want my code to be like this;
for x:=1 to 10
replace fieldname[x] with data
next

but it doesn't work. I have already used AFIELDS/FIELDNAME functions. need your help guys. i will very much appreciate if you can help me. tnx.
 
Your method refers to the field name as an array element. Try this


for x:=1 to 10
cField := 'fieldname' + ltrim( str( x ) )
replace &cField with data
next
 
An extra note...make sure the field name is not more than ten characters.
 
Is there a way to create an array of index files from a table of indexes so that the set index to command can be automatically generated from the array?

 
fizbell, regarding your question, yes there is a way to maintain a list of index names to use for the set index to command...
make a dbf whose record has two fields, (1) dbf name, and (2) the 'set index to string' contents. ie
\-------"Master.dbf"---------------------/
"Customer.dbf" "Cust1.NTX,Cust2.NTX"
"Prices.dbf" "PNOrd.NTX", "RegionOrd.ntx"

seek or locate the dbf name, then reference the 2nd field. ie

use Customer
set index to &Master->field2 // or whatever the name of field 2 is!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top