Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to tell column number and max num columns?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00505318
Message ID:
00505332
Vues:
20
>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
USE Mytable
* The number of columns in a table
lnMaxColNum = FCOUNT()

* Now find the filed number for specified column
lcColName = "FIELD1"
lnColNum = 0
FOR i=1 TO lnMaxColNum 
    IF FIELD(i) == lcColName
        lnlnColNum = i
        EXIT
    ENDIF 
ENDFOR
IF lnlnColNum > 0
    * the column number is in lnlnColNum
ELSE
    * No such column
ENDIF
or you can use combination of AFIELDS() and ASCAN
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform