Код: Выделить всё
select * from NameTab into TabSel browse * from TabSel
Код: Выделить всё
Include "MapBasic.def"
Declare Sub Main
Declare Sub DLG
Declare sub NameColList
Declare Sub GetColList(ByVal tbl as String)
Declare sub GroupCol
Dim TableList () as String
Dim ColList () as String
Dim TableNumDialog as SmallInt
Dim ColNumDialog as SmallInt
Sub Main()
Dim i, j as Integer
i = NumTables ()
ReDim TableList(i)
For j=1 to i
TableList(j) = TableInfo(j, TAB_INFO_NAME)
Next
Call DLG
End Sub
Sub DLG
Dialog
Title "Dialog"
Width 150 Height 280
Control ListBox
Position 9, 19
Width 133 Height 107
Id 1
Title From Variable TableList
' Into TableNumDialog
Calling NameColList
Control PopupMenu
Position 9, 138
Width 133
Title From Variable ColList
Id 2
' Into ColNumDialog
Control ListBox
Position 9, 171
Width 133 Height 43
Control StaticText
Position 9, 9
Width 58 Height 8
Title "Выбор таблицы"
Control StaticText
Position 9, 128
Width 46 Height 8
Title "Выбор поля"
End Sub
Sub NameColList
Dim ind, i, j as Smallint
ind = ReadControlValue(1)
Call GetColList(TableList(ind))
if UBound(TableList)=0 Then
Alter Control 2 Title "Нет"
Else
Alter Control 2 Title From Variable ColList
end if
Call GroupCol
End Sub
Sub GetColList(ByVal tbl as String)
Dim i, j as Smallint
i = TableInfo (tbl, TAB_INFO_NCOLS)
ReDim ColList(i)
For j=1 to i
ColList(j) = ColumnInfo(tbl, "col" & j,COL_INFO_NAME)
Next
End Sub
Sub GroupCol
Dim ind_NameTab, ind_NameCol as Smallint
Dim NameTab, NameCol As String
ind_NameTab = ReadControlValue(1)
ind_NameCol = ReadControlValue(2)
NameTab = TableList(ind_NameTab)
NameCol = ColList(ind_NameCol)
' Print NameTab
' Print NameCol
select NameCol from NameTab into TabSel
browse * from TabSel
End Sub