Hello Cameron,
Thursday, March 27, 2003, 1:34:24 AM, you wrote:
CC> Listers,
CC> I have a dialog with a pop up control that lists all my open tables. I
CC> select a table and then hit OK to process some information. I use the
CC> following code to read the value from the pop up to get the name of the
CC> table, but my program will not compile an I get an error when I try to
CC> read a value from the table using the variable as the table name:
CC> dim dentab as string
CC> dim covtab as string
CC> dim pop_state as string
CC> dim n_rows as integer
CC> dim I as integer
CC> dentab = Tableinfo(ReadControlValue(9007),TAB_INFO_NAME)
CC> covtab = Tableinfo(ReadControlValue(9008),TAB_INFO_NAME)
CC> n_rows = Tableinfo(dentab,8)
CC> For I = 1 To n_rows
CC> Fetch Rec I from dentab
CC> pop_state = dentab.STATE ' this is where the comile error
CC> "Unrecognized Command: .." occurs
CC> all the other commands work fine. I've tried using an alias type for the
CC> pop_state variable but to no avail. Anyone have a suggestion. This seems
CC> pretty simple, but maybe I'm missing something.
CC> Cameron
For example we have such dialog:
-----------------------------------------------------------------------------------
Sub DualListBoxDlg_Execute
Dialog
Title "Test"
Width 265 Height 122
Calling DualListBoxDlg_OnShow
Control OKButton
ID btnOK
Title "OK"
Position 197, 4
Width 65 Height 15
Calling btnOK_OnClick
Control CancelButton
ID btnCancel
Title "Cancel"
Position 197, 22
Width 65 Height 15
Calling btnCancel_OnClick
Control PopupMenu
ID TablesPopupMenu
Title ""
Position 44, 82
Width 97 Height 13
Value 0
Calling TablesPopupMenu_OnClick
End If
-----------------------------------------------------------------
Let TablesPopupMenu = 997. Define global variables like this:
-----------------------------------------------------------------
'//{$BEGIN GLOBALS FOR CONTROL TablesPopupMenu}
Global TablesPopupMenu_sTableName As String
Global TablesPopupMenu_sTablePath As String
Global TablesPopupMenu_saLayers() As String
Global TablesPopupMenu_WinID As Integer
Global TablesPopupMenu_CurrTable As String
Global TablesPopupMenu_LayerCount As Integer
Global TablesPopupMenu_I As Integer
'//{$END GLOBALS FOR CONTROL TablesPopupMenu}
-----------------------------------------------------------------
Initialize array in dialog calling sub
-----------------------------------------------------------------
Sub DualListBoxDlg_OnShow
'//{$BEGIN INIT CODE FOR CONTROL TablesPopupMenu}
ReDim TablesPopupMenu_saLayers(0)
TablesPopupMenu_WinID = FrontWindow()
If TablesPopupMenu_WinID Then
TablesPopupMenu_LayerCount = MapperInfo(TablesPopupMenu_WinID, MAPPER_INFO_LAYERS)
Else
TablesPopupMenu_LayerCount = 0
Alter Control TablesPopupMenu Title "-No Tables Is Open-" Disable
End If
If (NumTables() > 0)AND( TablesPopupMenu_LayerCount <> 0) Then
ReDim TablesPopupMenu_saLayers(TablesPopupMenu_LayerCount)
For TablesPopupMenu_i = 1 to TablesPopupMenu_LayerCount
TablesPopupMenu_saLayers(TablesPopupMenu_i) = LayerInfo(TablesPopupMenu_WinID,
TablesPopupMenu_i, LAYER_INFO_NAME)
Next
Alter Control TablesPopupMenu Title From Variable TablesPopupMenu_saLayers
End If
'//{$END INIT CODE FOR CONTROL TablesPopupMenu}
End Sub
-----------------------------------------------------------------
When you will change popupmenu item - following code will execute
-----------------------------------------------------------------
Sub TablesPopupMenu_OnClick
If UBound(TablesPopupMenu_saLayers) > 0 Then
TablesPopupMenu_sTableName = LayerInfo(TablesPopupMenu_WinID, ReadControlValue(
TablesPopupMenu), LAYER_INFO_NAME)
print "TablesPopupMenu_sTableName ="+TablesPopupMenu_sTableName
End If
End Sub
--
Best regards,
Vladimir Lashin
microOLAP Technologies LLC
-------------------------------------------------------------------------------------------------------
MBBuilder - Visual Development Tool for MapBasic -
http://www.microolap.com/products/gis/mbbuilder.htm
Raster Handler for ERDAS Imagine to MapInfo -
http://www.microolap.com/products/gis/imgrhl.htm
MapInfo Callbacks Manager ActiveX - http://www.microolap.com/products/gis/micmx.htm
EasyMap VCL - http://www.microolap.com/products/gis/easymap.htm
-------------------------------------------------------------------------------------------------------
mailto:[EMAIL PROTECTED]
http://www.microolap.com/gis/ - GIS related products
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 6124