Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to tell column number and max num columns?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00505318
Message ID:
00505323
Views:
21
Hi Brenda,

For number of columns in a table:

LOCAL laMyArray, lnColumns
DECLARE laMyArray[ 1, 16 ]
lnColumns = AFIELDS( laMyArray, "MyTable" )

The array laMyArray now has sixteen columns and one row for each field/column in the MyTable table. Then, to get the column number for a particular name,
you could use a combination of ASCAN() and ASUBSCRIPT() in this manner:

LOCAL lnRow
lnRow = ASUBSCRIPT( laMyArray, ASCAN( laMyArray, "MyFieldName" ), 1 )

The variable lnRow now contains the array row (ie, table column number) of the field/column specified in MyFieldName.

HTH.

>I have a table with many columns. I am in charge with bringing the many years out of date documentation up to date. Would like to know that column abc is column number 121, and would also like to know the number of columns in a table. How can I tell the number of columns a table has and the specific column number for a given column name?
>
>Thanks
>
>Brenda
Evan Pauley, MCP
Positronic Technology Systems LLC
Knoxville, TN

If a vegetarian eats vegetables, what does a humanitarian eat?
Previous
Reply
Map
View

Click here to load this message in the networking platform