home *** CD-ROM | disk | FTP | other *** search
- /* Program to display Paradox table fields and their types */
- /* By Peter M. Jagielski, Borland International */
- /* Make sure the Turbo C project file for STRUCT.C contains the 2 lines:
- STRUCT.C
- TABLETS.LIB */
-
- #include <stdio.h>
- #include <table.h>
-
- main(argc,argv)
- unsigned int argc; /* number of command line parameters */
- char *argv[]; /* file name */
- {
- TABLE *tableptr; /* pointer to structure TABLE */
- unsigned int numfields,i;
- char fieldname[25],fieldtype[4];
-
- if (argc == 1) /* if not table specified */
- {
- puts("Syntax: STRUCT <tablename>");
- exit(0);
- }
-
- if ((tableptr = (TABLE *) tOpen(argv[1])) == NULL) /* if table exists */
- {
- printf("Table \"%s\" doesn't exist",argv[1]);
- exit(0);
- }
-
- numfields = tNumFlds(tableptr); /* get number of fields */
- printf("Table \"%s\" has %d fields:\n",argv[1],numfields);
- puts("Field Type Field Name");
- puts("---------- -------------------------");
- for (i = 1; i <= numfields; i++)
- {
- tFldName(tableptr,i,fieldname); /* get name of field */
- tFldType(tableptr,i,fieldtype); /* get field type */
- printf(" %4s %s\n",fieldtype,fieldname);
- }
- tClose(tableptr); /* close the table/file */
- }
-
-