Marko Moric
unread,Dec 2, 2009, 5:57:16 AM12/2/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to MapInfo-L
I still didn`t manage this code to work the way i want to.So i wrote a
new code with the same issues,
list all open tables,
choose table,
choose a column under selected table,
and type in criteria for filtering data from .TAB
So,as u can see i`m trying to make dynamically a SQL query for
searching the data.
and this is the code :
Include "mapbasic.def"
Declare Sub Main
Declare Sub FillColumnlist
Declare Sub PrintColumn
Global a_1, kolona,kolona1, tabela as String
dim strColList() as string
dim strTableList() as string
Dim aCol As Alias
dim intCounter,intTableid,intColumnid,intTabnum,intColnum as integer
dim strColname,strTabname,a1 as string
sub main
'Get the number of tables currently open and redimension the table
array.
intTabnum = NumTables()
redim strTablelist(intTabnum)
'Populate the table array with the table names
for intCounter = 1 to intTabnum
strTablelist(intCounter) = TableInfo(intCounter,TAB_INFO_NAME)
next
'Get the number of columns in the first table and redim the column
array
intColnum = NumCols(strTablelist(1))
redim strColList(intColnum)
'Populate the column array with the column names
for intCounter = 1 to intColnum
strColList(intCounter) = ColumnInfo(strTablelist
(1),"COL"+intCounter,COL_INFO_NAME)
next
'initialize the intTableid variable so that it always points to a
table
intTableid=1
'Create the dialog with two popupmenus and an OK button
dialog
title "Izaberi tabelu i kolonu"
control popupmenu
ID 1
calling fillcolumnlist
title from variable strTablelist
control popupmenu
ID 2
title from variable strColList
control StaticText
Title "Kriterijum"
ID 3
Control EditText
Value a_1
Into a_1
control OKButton
calling PrintColumn
If CommandInfo(CMD_INFO_DLG_OK) Then
a1 = a_1 + "%"
tabela = strTabname
kolona1 = ColumnInfo(tabela, "col1", COL_INFO_NAME)
aCol = strTabname & "." & kolona1
'Run Command "Select * From " & tabela & " Where " & tabela & "
LIKE " & a1
'Run Command"SELECT * FROM " + tabela + " Where " + kolona1 + "= "
+ a1 + "Into SELECTION"
SELECT * FROM tabela Where aCol LIKE a1 Into SELECTION
BROWSE * FROM SELECTION
end if
end sub
'This procedure re-populates the column array with the column names in
'the table the user picked from the table popup menu.
sub fillcolumnlist
intTableid = ReadControlValue(1)
strTabname = TableInfo(strTablelist(intTableid), TAB_INFO_NAME)
intColnum = NumCols(strTabname)
redim strColList(intColnum)
for intCounter = 1 to intColnum
strColList(intCounter) = ColumnInfo(strTablelist
(intTableid),"COL"+intCounter,COL_INFO_NAME)
next
'Update the column popup menu with the new column array
Alter Control 2 Title From Variable strColList
end sub
sub PrintColumn
'Get the name of the column the user picked and print it on screen.
intColumnid = ReadControlValue(2)
strColname = ColumnInfo(strTablelist
(intTableid),"COL"+intColumnid,COL_INFO_NAME)
kolona = strColname
'print kolona
'print strColname
end sub