Unfortunately, there is no built in 'search & replace' functionality in the MapBasic language. The way I've always done this is to use a custom function and include this in any projects where I've needed to search/replace.
My search and replace function takes a string as input and returns a string as output, so you could use this in an update query.
e.g. UPDATE myTable SET myTextField = SearchReplace(myTextField, ",", " ")
Here's the function:
'=========================================
'// <summary>
'// Replace part of a string with another string
'// </summary>
'-----------------------------------------
Function SearchReplace(ByVal strInput as String, ByVal strReplace as String, ByVal strReplacement as String) as String
Dim iPos as Integer
Dim strOut as String
Dim i as Integer
iPos = InStr(1, strInput, strReplace)
If iPos < 1 then '// nothing to replace, return original string
SearchReplace = strInput
Exit Function
End If
While iPos > 0 '// loop until nothing left to replace
If iPos > 1 then
strOut = Left$(strInput, iPos - 1)
End if
strOut = strOut & strReplacement
If iPos + Len(strReplace) - 1 < Len(strInput) then
strOut = strOut & Mid$(strInput, iPos + Len(strReplace), Len(strInput) - (iPos + Len(strReplace)) + 1)
End If
strInput = strOut
iPos = InStr(iPos + 1, strInput, strReplace)
Wend
SearchReplace = strOut
End Function
Best Answer
CommandInfo() is a useful function which retains all information pertaining to recent events in MapBasic. I cannot remember, off hand, all of the items it returns, but I'd check that for a starting point
EDIT
I have just looked at this, and you need to use the CommandInfo() function thus:
NOTE
This only applies if the toolbutton was defined with a draw mode that allows dragging, e.g., DM_CUSTOM_LINE.