Despite my 3+ years experience with MapInfo, I've barely scratched the surface of
MapBasic (this is my first post). I want to create a simple dialog with popup menus,
but I'm having trouble with the returned values from the popup menus. I've used
ReadControlValue() to check the values, which are returned as 0,1,2 or 3, not the
string values in the menu itself. Converting these values into the intended string
values is proving harder than I thought. Whenever I put the variable through a
logical test to set a different variable to the desired value, it treats it as though
the value is 0.
Here's the code for the dialog, which prompts a user to select a Year and a Quarter.
Dim Yearselect as smallint
Dim Quarterselect as smallint
Dialog
Control GroupBox
ID 1
Title "Select Year and Quarter of Data"
Position 5, 0 Width 153 Height 30
Control PopupMenu
ID 2
Title "02;03;04;05"
Position 35, 12
Into Yearselect
Control PopupMenu
ID 3
Title "1Q;2Q;3Q;4Q"
Position 100, 12
Into Quarterselect
Control OKButton
Calling OKhandler
Control CancelButton
Here's the code for the part where I'm trying to establish string values representing
the last two digits of the year selected, and the selected quarter in the format "#Q".
I'm sure there is probably a better way to do this.
Dim Quarter as string
Dim Year as string
Sub OKhandler
Print "Value of Yearselect is.." + ReadControlValue(2)
Print "Value of Quarterselect is.." + ReadControlValue(3)
Quarter = str$(Quarterselect) + "Q"
If Yearselect = 0 then
year = "02"
Elseif Yearselect = 1 then
year = "03"
Elseif Yearselect = 2 then
year = "04"
Elseif Yearselect = 3 then
year = "05"
End If
Print "You have selected the year" + Year
Print "You have selected the quarter" + Quarter
End Sub
The initial print statements in this sub show that the control does return a value,
but the final print statements show the Year as "02" and the quarter as "0Q",
regardless of what I select from the menu.
Lawson Key
CenturyTel
318.340.5335
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 10852