Get the name or alias of the table.
The <TBL>.NAME_GET() method returns the Alias of the table referenced by <TBL>. The returned name will not include the drive, path or extension (.dbf) of the referenced table. If the table pointer <TBL> references a set, the Alias of the set's primary table is returned. The Alias is the same as the table name (excluding drive and path and file extension) for the first instance of that table that is opened in a session. However, if more than one instance of a table is opened, Alpha Anywhere will automatically assign each instance a unique Alias. Note : The full name and path of the primary table or set in a session is stored in the A_DB_CURRENT system variable. To obtain only the path of the current table or set, use A_DB_CURRENT_PAT H. Both of these system variables are character strings that are automatically assigned by Alpha Anywhere.
Type the following commands in the Interactive window.
dim tbl_first as P dim tbl_second as P tbl_first = table.open("d:\a5\a_sports\customer.dbf") tbl_second = table.open("d:\a5\a_sports\customer.dbf") 'This will show "customer" as the alias ? tbl_first.name_get() 'This will show "customer1" as the alias ? tbl_second.name_get() tbl_first.close() tbl_second.close()
This script displays the alias of the primary table in a session, the full name and path of the primary table or set, and the path of the current table or set.
dim tbl as P tbl = table.current() trace.writeln(tbl.name_get()) trace.writeln(A_DB_CURRENT) trace.writeln(A_DB_CURRENT_PATH)
This script lists the names of open tables.
dim tbl as P count = 1 while .T. tbl = table.current(count) 'Check to see if the table pointer, tbl, is valid. 'If not, then there are no more open tables. if .not. is_object(tbl) exit while else trace.writeln(tbl.name_get()) count = count + 1 end if end while