Terry,

MapBasic does not process the "Into" clause of a Dialog Control statement until the dialog allowed to finish. How do you "finish" a dialog statement? A user action on an OKButton, a CancelButton or a Dialog Remove statement.

So how can you get the value of the lnOSID value *prior* to the dialog closing? Use a handler function like your REFRESH_ONDS_DETS_DIALOG sub and use the ReadControlValue function.

I would rewrite your code as follows:

'*** ADDED A SIMPLE DEFINE STATEMENT FOR OUR CONTROL ID
Define DEF_POPUPMENU_ID  100

Sub ONDS_DETS_DIALOG
 ...
 Dialog
 ...
         Control StaticText
                Position 15, 157
                Title "&Other Services:"
Control PopUpMenu Position 70, 156
                Width 140
                Title from Variable laZGsOnDServs
'*** ADDED THE FOLLOWING LINE SO WE CAN REFERENCE THIS CONTROL AT RUNTIME
                ID DEF_POPUPMENU_ID
                Value 1
                Into  lnODSID
' NOTE laZGsOnDServs and lnODSID "global" to this module
         Control Button
                Title "&Refresh"
                Calling REFRESH_ONDS_DETS_DIALOG
         Control OKButton
End Sub

'________________________________________________
Sub REFRESH_ONDS_DETS_DIALOG
' __________________________
note "lnODSID = " + str$( lnODSID)
'*** ADDED THE FOLLOWING LINE TO READ THE CURRENT VALUE OF THE POPUP MENU
 lnODSID = ReadControlValue(DEF_POPUPMENU_ID)

 lcODService            = PARSE_ONDS( laZGsOnDServs, lnODSID )
 Dialog remove
 Select * from csrODS
         where csrODS.Service = lcODService
         into csrTempODS
 Call ONDS_DETS_DIALOG
End Sub


I hope this helps....

- Ian Erickson

Terry McDonnell wrote:

Hi List

Pleas consider the following code.  I'm interested in the variable,
lnODSID, which takes the index of the pop-up selected item.  Now this is
dim'd at the module level and is thus "global" to all subs therein.

After I've selected an item (string with a code embedded in it), and hit
the "refresh" button, the call to REFRESH_ONDS_DETS_DIALOG first calls
PARSE_ONDS, which takes the selected array element and strips out the
code part, which is then used in finding the relative rec, for
redisplaying in the dialog.

At first I was reusing another var, which had been used to select a
particular rec from the same table, but the call to PARSE_ONDS crashed
with . There are only 2-3 values in the combo, but the variable remained
at 42, what it was when first used.

So tried using a different var, lnODSID.  If I don't initialise it, it
is returned as 0 - so "subscript out of range" error (note thus ignoring
the initial set Value of 1).  So I initialise it to 1, and all I get in
is array element 1 (so PARSE_ONDS doesn't crash) but only the first rec
in the table each time.

SO, essentially, the dialog isn't giving me the output I want.  You may
notice that the dialog calls a procedure which then "recursively" calls
the same dialog, after removing it.  But the error occurs before that,
i.e. before MB realises the dialog is to recurse.

I don't know of any other way of refreshing the dialog with new data.

Can anyone please explain this conundrum?

'ppreciate it

Terry McDonnell
------------------------------------
Sub ONDS_DETS_DIALOG
 ...
 Dialog
 ...
         Control StaticText
                Position 15, 157
                Title "&Other Services:"
Control PopUpMenu Position 70, 156
                Width 140
                Title from Variable laZGsOnDServs
                Value 1
                Into  lnODSID
' NOTE laZGsOnDServs and lnODSID "global" to this module
         Control Button
                Title "&Refresh"
                Calling REFRESH_ONDS_DETS_DIALOG
         Control OKButton
End Sub

'________________________________________________
Sub REFRESH_ONDS_DETS_DIALOG
' __________________________
note "lnODSID = " + str$( lnODSID)
 lcODService            = PARSE_ONDS( laZGsOnDServs, lnODSID )
 Dialog remove
 Select * from csrODS
         where csrODS.Service = lcODService
         into csrTempODS
 Call ONDS_DETS_DIALOG
End Sub

'________________________________________________
Function PARSE_ONDS( tcODSArray() as String, tnODSSelID as SmallInt) as
String
' _________________
' Get the On-d Service ID from the global array of ID - Desc, used in
array for list box
' _________________________________
 Dim    lcOnDSString, lcODS     as String,
                lnEndPos                                as SmallInt

 lcOnDSString   = RTrim$( tcODSArray( tnODSSelID))
 lnEndPos               = InStr( 1,  lcOnDSString,  " - ") - 1
 lcODS                  = Left$( lcOnDSString, lnEndPos)
' On-D S code part of string
 PARSE_ONDS             = lcODS
End Function

_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l


--
Ian Erickson
AnalyGIS, LLC

See AnalyGIS at work: http://65.39.85.13/google/ http://65.39.85.13/virtualearth/

_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to