KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Check if table exists
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: April 7, 2006
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

It is prudent to check whether a table exists before executing a command with table number as the parameter. Examples of the commands that rely on a table number are TABLE, FIELD, and GET FIELD PROPERTIES. The following method checks if the table exists based on the passed table number, and return a boolean value as an answer.


C_BOOLEAN($0)  ` returns True if the table exists
C_LONGINT($tableNum;$1)  ` table number

$tableNum:=$1

ARRAY TEXT($tableTitles;0)
ARRAY LONGINT($tableNums;0)

GET TABLE TITLES($tableTitles;$tableNums)

If (Find in array($tableNums;$tableNum)#-1)

$0:=True

Else

$0:=False

End if