Please i need some help for my Mapbasic training, whith the help of some expert here i could made some improvement as beginner to plot the site and links telecom in map .
Now i need to make some update to the obj of link table which i want it to appear in different colors depending on the frequency range rather than making new selection.
This is the line code with update statement :
update linkT Set Pen= MakePen(3, 9, RED) where site_1_ch_ID,2 Like "15%"
i will be more than grateful for any help
I did get your problem and have some suggestions that if you wish can apply. I had developed a similar tool for some telecom company some years back.
I suggest you to create different buttons for your frequency ranges like RxLevel,TxLevel some of which I remember . When a user clicks on these buttons the color of the links changes and the legend is also visible on the right bottom for information.
Md. Aslam Khan
You need to do this using a function. For example, see below for code that removes the background fill of region objects; hopefully this helps.
Update polygonSelection Set obj = removeObjBckGrnd(obj)
Function removeObjBckGrnd(ByVal oOverlayPoly As Object) As Object
' - oOverlayPoly is a polygon object
' - Returns an object that is the same as the input object except that if a background was in existence it has now been removed
Dim oNewObj As Object
Dim brushPoly As Brush
Dim nBrushPattern As Integer
Dim nBrushForeColour As Integer
Dim nBrushBackColour As Integer
Dim brushNew As Brush
' Retrieve the current brush
brushPoly = ObjectInfo(oOverlayPoly, OBJ_INFO_BRUSH)
' Retrieve current brush attributes
nBrushPattern = StyleAttr(brushPoly, BRUSH_PATTERN)
nBrushForeColour = StyleAttr(brushPoly, BRUSH_FORECOLOR)
nBrushBackColour = -1 ' Transparent background required
brushNew = MakeBrush(nBrushPattern, nBrushForeColour, nBrushBackColour)
oNewObj = oOverlayPoly
Alter Object oNewObj Info OBJ_INFO_BRUSH, brushNew
removeObjBckGrnd = oNewObj
The STYLELib module from the mbLibrary (found here https://github.com/PeterHorsbollMoller/mbLibrary/blob/master/STYLELib.def) holds a number of functions that can be used to change the styling on objects.
To do what you want you need to combine your update statement with a query to select the records that you want to change:
Dim penNew As Pen
penNew = MakePen(3, 9, RED)
Select * From linkT Where site_1_ch_ID Like "15%" Into __UPDATE NoSelect
Update __UPDATE Set OBJ = STLAlterPen(OBJ, penNew)
Close Table ___UPDATE
You have to copy the function STLAlterPen into your source code file or include the entire module in your MapBasic Project File.
Also note that I changed site_1_ch_ID,2 to site_1_ch_ID suspecting this was the column you are referring to.
First I'm so grathfull for your support and your concern ,I'll try to look for the STLALterPen and copy it as function in my application .
I'll feedback you as soon as possible.
Sorry for the delay as Ii'was off in last couple day.
?Dear Peter and Khan ;
Please be informed that I got some errors when coping the function STLALTERPEN .
It seen my MAPBAIS IDE didn't kwon the function STLObjectHasPen(oObj).
even the include statement I got error in - Include "ERRORLib.def"-Include "STYLELib.def.
I attache my the application , so please have look to spot the issue in your free time.
About my application as first steps I want my links appear in different Color depending on the frequency band as I have three band "15" & 25" & 38".
After as second step I'll make button to ask the user for prompt chose the frequency channel to be able after that to make selection in new map containing only that frequency channel.
Please accept my warmest regard and respect.
I had a look at your code and I can see that you added the declaration of the code. The problem is that the functions is referring to other functions in the mbLibrary.
You can do one of two things to get rid of this error.
You can either add this function to your code. This function is also part of the STYLELib.mb module. Just copy it and add the declaration.
Or if you are certain your objects always are object types with a Pen just remove the use of the function.
2. Error Handling
The modules all use error handling functions that are in another module called ERRORLib.mb. Again to avoid the compile errors, you need to stop using these functions.
Here is a rewrite of the function with out the use of the other functions from the mbLibrary:
Function STLAlterPen( ByVal oObj As Object 'Object whoes style to change
, ByVal penNew As Pen 'New Pen style to assign
) As Object
OnError GoTo ErrorOccured
STLAlterPen = oObj
Alter Object oObj
Info OBJ_INFO_PEN, penNew
Print Err() & " " & Error$() & ": STLAlterPen"
Let me know how this works for you
Yes it working no error in compiling when bypassing some function which need Library including;
Please have look to my attached file ,I made some update to adjust the code to my purpose.
Now i have to go to the next steps to make it more interactive with the users.
Really you are life saver , thanks you very much you and Mr Khan as you helped me so much.
I still need you and hope I'm not bothering you 😓
I would suggest that you create a function for your dialog. The function will return the frequency entered by the user. You can then use this value to query your data.
The function could look like this:
Function FilterFREQ() As String
Dim TxFreq as string
FilterFREQ = ""
Title "select Frequency"
If Not CommandInfo(CMD_INFO_DLG_OK) Then
FilterFREQ = TxFreq
Also have a look at the source code where I added the function.
as you recommend I made the selection as independent function which ask the user to write the wanted frequency .
After update and test please find below the differents issue that I have to fixe:
the pushbutton is desactivated meanwhile I need to push as soon as I want to seek the wanted Frequency.
Before any seek i need to clean up all the previous table and map and keep only the site and linkT tables.
Till now these are my first concerns which I still need help to fixed .
thanks in advance.
The problem with the PushButton was caused by a misunderstanding, I assume. The handler for the PushButton should be given via the "Calling" keyword. You had written "Call".
I have made a few minor changes but basically I think the tool should work. I have not tested it.
Also note that I recommend that you change the Filter procedure to use a Query table instead of saving a copy of the selected records into a new base table.
See attached source file
Please have a look to the tool I made some new feature to make it more interactive with the users.
Meanwhile I need some support to fixe the following issue :
is it possible to have label composed by two items from different column , i want the line object with label composed from col28 <>col29 , I have already managed to do it with only col28.
I want after each cursor clic on link in map window (which represents MW links) it will show dialog showing us some information from the some desired column like (Col 28 & col29 & col 40 ...) like the function "Info " of mapbasic which display all the parameters after clic on map items (I have tried with Toolhandler but could find out the solution
Finally is it possible to launch this application from the excel sheet which exist all the data I'm handling with VBA button command instead of registering the file in txt format and then open it from mapinfo tool.
Hope I'm not disturbing you and Thanks in advance.
I think it's time to break this question into multiple question so that we can close them off individually as we get thru them and for other people to better find and learn from these.
Let me answer the first of your questions:
You can combine multiple columns in your label expression. Typically, you will combine values from a column with fixed text. In your case, if I understand what you want to do, you can use this expression:
col28 + " <> " + col29
Please raise the other questions you have as individual questions under the MapBasic topic
Totally agree with you and sorry for this mess.
Thanks again and best regards.