----- Original Message -----
From: Fran�ois Molle <[EMAIL PROTECTED]>
To: MAPINFO-L <[EMAIL PROTECTED]>
Sent: Thursday, July 06, 2000 8:20 AM
Subject: MI MB: how to check if column XXX exists in table TTT


> Dear All
>
> Apparently, there are no function to know if column XXX exists in table
> TTT (is there ?)
> So I built a loop on all columns name to check whether one is equal to
> XXX.
>
> TTT as Alias, tesname as string
>
> For i=1 to Nbcolumn
> testname=ColumnInfo(TTT,"col"+str$(i),COL_INFO_NAME)
> If testname=TTT then print "OK" end if
> next
>
> For some reason, it does not accept this and gives the error:
> "Variable or Field TTT not defined"
> Is it because of the mismatch of variables, String and Alias ?
> If I use testname=str$(TTT) is does not work either.

1.  Always use strings (literals or variables as appropriate) for
column names and table names. You will thank me later.

2. The only way to detect if a column exists or doesn't exist
is to use ColumnInfo.   If the column doesn't exist, MapBasic
will raise an error.   You must write an error handler to
intercept this error and make the routine retrun FALSE
instead of terminating the application.

Hope this helps.
Spencer

2.


----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

Reply via email to