Skip to main content
Version: Next

Get last table number

Get last table number -> Function result

ParameterTypeDescription
Function resultLongint🡐Highest table number in the database

Description

Get last table number returns the highest table number among the tables in the database. Tables are numbered in the order in which they are created. If no table has been deleted from the database, this command then returns the number of tables present in the database. In the case of repeated loops on the table numbers of the database, you must use the Is table number valid command in order to check that the table has not been deleted.

Example

The following example builds an array, named asTables*,* with the names of tables defined in the database. This array can be used as a drop-down list (or tab control, scrollable area, and so on) to display the list of the tables, within a form:

 ARRAY TEXT(asTables;Get last table number)
 If(Get last table number>0) //If the database does contain tables
    For($vlTables;Size of array(asTables);1;-1)
       If(Is table number valid($vlTables))
          asTables{$vlTables}:=Table name($vlTables)
       Else
          DELETE FROM ARRAY(asTables;$vlTables)
       End if
    End for
 End if

See also

Get last field number
Is table number valid
Table name