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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fieldget function in vfp ?

Status
Not open for further replies.

engan

Programmer
Jul 15, 2001
53
ID
Is there a function in vfp to get the data from a field based on the field position instead of the name of the field.

for example
my field is :
idnumber c 5
name c 30
balance1 n 17 2
balance2 n 17 2
balance3 n 17 2

fieldget(1) it will get the first field (idnumber)
fieldget(2) it will get the second field (name)
fieldget(3) it will get the third field (balance1)

engan

 
The function field() returns the field name of a field referenced by number

Therefore in your file the commands

use yourfile
browse field (field(1)),(field(2)) &&will open the browse window with the idnumber and name fields.

or
store field(1) to m.field
?&m.field &&will display the value in the idnumber field






 
Another useful function is afields(), which returns the count of columns in the current table, and creates an array (which can be used as an alternative to field() in and of itself).

e.g.

For counter = 1 to afields(MyArray)
?MyArray(counter,1) && returns field name
?MyArray(counter,2) && returns field type
?MyArray(counter,3) && returns field width
?MyArray(counter,4) && returns field decimals
EndFor

 
I try it and it works. Thanks guys for your info.

Engan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top