On Sat, May 27, 2006 at 09:35:53AM +1000, Boyd Townsend wrote:
> I am attempting to request through a DDE statement the currently active
> MBX's and then terminate all active/loaded MBX's except the one that is
> making this assesment.
>  
> I have so far been able to request this info and display those results
> in a print window.
>  
> Can anyone assist me in being able to take this information and then
> terminate these active MBX's trough a Terminate Application Statement
> with exception of the MBX that is carrying out this task?

The result returned from DDERequest$ is a tab-delimited string, and that's
hard to see in the message window. The other trick is how to search for a
tab character in a string and ""+Chr$(9) does the trick (the null string in
the double quotes guarantees that the result will be a string.)

The following little program shows you how to parse this to get a list of
all running MBX's. I assume you'll know which one is the caller, but my
guess is that it will probably always be the last one if your program was
loaded last.

' ----- 
Include "MapBasic.def"
Declare Sub Main

Sub Main
Dim nChan As Integer
Dim sTopics As String
Dim sList(), sText As String
Dim i, j, p As Integer

  nChan = DDEInitiate ("MapInfo", "System")
  sTopics = DDERequest$ (nChan, "Topics")
  DDETerminate nChan

  ' Break up tab-delimited string into array; save only the MBX's
  p = 1
  j = 1
  p = InStr(j, sTopics, ""+Chr$(9))
  Do While p > 0
    sText = Mid$(sTopics, j, p-j)
    If Right$(sText, 4) = ".MBX" Then
      i = i + 1
      ReDim sList(i)
      sList(i) = sText
    End If
    j = p + 1
    p = InStr(j, sTopics, ""+Chr$(9))
  Loop
  sText = Mid$(sTopics, j, Len(sTopics)-j+1)
  If Right$(sText, 4) = ".MBX" Then
    i = i + 1
    ReDim sList(i)
    sList(i) = sText
  End If
  
  ' Display all mbx's
  CLS
  For i = 1 To UBound(sList)
    Print sList(i)
  Next
End Sub


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

Reply via email to