First of all, I think you should declare all the variables you are using in
subroutines. I'm surprised that the compiler lets you get away with not
doing this. Next, to get the value of strBox1 into the Process subroutine
you need to use the ReadControlValue() function, e.g. strBox1 =
ReadControlValue(5).

Also, this doesn't have anything to do with the problem, but I'd just like
to say that technique of using

  define x*8
  define y*8

to help you position controls in a dialog is one of the worst uses of the
define statement I can imagine. I know this is taught in the MapBasic
course, but I think it's a terrible solution to a kludgy dialog-creation
issue. It's the kind of clever construct that will whack you like stepping
on a rake in tall grass causing the handle to come up into your face at
speed.

If you ever try to declare the *variables* x and y in your program (not
an uncommon possibility in a GIS programming environmnet) and
you have this abomination in your code, you will get a very cryptic and
hard-to-debug error when you try to compile the program.

It would be better to define constants that don't look like possible
variables like this:

define _xchar*8
define _ychar*8

and even better not to use defines like this at all.

(Sorry, I just had to vent....)

- Bill Thoen

On Tue, Dec 20, 2005 at 09:26:06PM -0800, John Crouse wrote:
> I have attached code to a program I am working on.  My problem is that I I 
> can't get the input in the EditText box into the Sub Procedure that I need to 
> do several queries on.  I have tried to change the text to a value using the 
> "Val" command but when I test it using a Print statement, it always comes 
> back as a 0.  Any suggestions?
>    
>   TIA,
>    
>   John
>    
>     Include "mapbasic.def"
>   Include "icons.def"
>   Include "menu.def"
>    
>   define x*8
>   define y*8
>    
>   Declare Sub main
>   Declare Sub fillcolumnlist
>   Declare Sub Process
>   Dim strTablelist(), strTabName, strColList() as string
>   Dim intTableid, intColnum, intCounter, intTabnum, intColumnid as Integer
>   Dim strBox1, strBox2 as string
>   Dim one, two, three, four as Alias
>   Dim matrix_table as string
>    
>   Sub main
>   
>    
>   intTabnum = Numtables()
>   redim strTableList(intTabnum)
>    
>   for intCounter = 1 to intTabnum
>   strTablelist(intCounter) =Tableinfo(intCounter, TAB_INFO_NAME)
>   next
>    
>   intColnum = NumCols(strTablelist(1))
>   redim strColList(intColnum)
>   for intCounter = 1 to intColnum
>   strColList(intCounter) = ColumnInfo(strTablelist(1), "COL"+intCounter, 
> COL_INFO_NAME)
>   next
>    
>   intTableid = 1
>    
>   Dialog
>    
>   Title "Risk Matrix"
>   Width 40x Height 53y
>    
>   Control GroupBox
>   Title "Step 1 - Select Table, Columns, and Ranges:"
>   Position 1x, 1y
>   Width 37x Height 13y
>    
>   Control StaticText
>   Title "Select Table:"
>   Position 2x, 2.5y
>    
>   Control PopupMenu
>   ID 1
>   Position 12x, 2.5y
>   Title from variable StrTablelist
>   calling fillcolumnlist 
>   Width 12x
>   into one
>    
>   Control StaticText
>   Title "Select Actual Value:"
>   Position 2x, 5.5y
>    
>   Control PopupMenu
>   ID 2
>   Position 12x, 5.5y
>   Title from Variable strColList
>   Width 12x
>   into two
>    
>   Control StaticText
>   Title "Select Model Value:"
>   Position 2x, 8.5y
>    
>   Control PopupMenu
>   ID 3
>   Position 12x, 8.5y
>   Title from Variable strColList
>   Width 12x
>    
>   Control StaticText
>   Title "Select # of Ranges:"
>   Position 2x, 11.5y
>    
>   Control PopupMenu
>   Title "10;15;20"
>   ID 4
>   Value 3
>   Position 12x, 11.5y
>   Width 12x
>    
>   Control GroupBox
>   Title "Select High Value for Range:"
>   Position 1x, 15y
>   Width 37x Height 34y
>    
>   Control StaticText
>   Title "Range 1:"
>   Position 2x, 16.5y
>    
>   Control StaticText
>   Title "Range 2:"
>   Position 2x, 18.5y
>    
>   Control EditText
>   Position 7.5x, 16.5y
>   ID 5
>   Into strBox1
>   Width 10x
>    
>   Control EditText
>   Position 7.5x, 18.5y
>   ID 6
>   Into strBox2
>   Width 10x
>    
>   Control OKButton
>   Position 12x, 50y
>   ID 25
>   Calling Process
>    
>   Control CancelButton
>   Position 19x, 50y
>   ID 26
>   End Sub
>    
>   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
>   Alter Control 2 Title from Variable strColList
>   Alter Control 3 Title from Variable strColList
>   End Sub
>    
>   Sub Process
>   matrix_table = TableInfo(intTableid, TAB_INFO_NAME)
>   intColumnid = ReadControlValue(2)
>   two = ColumnInfo(strTableList(intTableid),"COL"+intColumnid,COL_INFO_NAME)
>   '**********At this point I would like to select the records from the table 
> that are above and/or below a certain value
>   'like the example below***************
>   'Select * from matrix_table where two > strBox1 and two < strBox2
>   End Sub
>    
> 
>    
>    
> _______________________________________________
> MapInfo-L mailing list
> [email protected]
> http://www.directionsmag.com/mailman/listinfo/mapinfo-l
> 
_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to