Convert style definition to string [MapBasic]

Skip to first unread message


Feb 1, 2023, 5:13:33 AMFeb 1
to MapInfo-L
I have defined style for MI objects that I insert/edit using MB tool. 
Something like:
Define MMES_SYM (35,16711680,10,"MapInfo Symbols",0,0)

Now, I need to create string that will store this definition.
However it complains about '(' character. 

I tried both with str$(MMES_SYM)and adding quotes at beginning and end, with no luck. Is it possible to this kind of conversion

Peter Horsbøll Møller

Feb 1, 2023, 6:56:08 AMFeb 1



You should be able to convert a string to a Symbol variable.

But the string needs to look like this:


Dim symNew As Symbol
Dim sSym As String
= CurrentSymbol()
= sSym


Alternatively, you can use a function that takes your string and then converts that into a symbol.

In the STYLELib that is part of my MapBasicLib, there are functions that helps you cast from styles to string and from strings to styles.


They take a comma separated string with elements and create new styles from these.


Here’s one example:

Function STLText2Symbol(ByVal sSymbol As String) As Symbol


Dim   arrItems() As String,

      nNumItems As Integer


OnError GoTo ErrorOccured


STLText2Symbol = CurrentSymbol()


      nNumItems = STRINGSplit(sSymbol, ",", arrItems)


      If nNumItems = 3 Then

            'MapInfo 3.0 symbol set

            STLText2Symbol = MakeSymbol(Val(arrItems(1)), Val(arrItems(2)), Val(arrItems(3)))


      ElseIf nNumItems > 3 Then

            Do Case arrItems(1)

                  Case "1"

                        'MapInfo 3.0 symbol set

                        STLText2Symbol = MakeSymbol(Val(arrItems(2)), Val(arrItems(3)), Val(arrItems(4)))


                  Case "2"

                        'TrueType font as the symbol

                        STLText2Symbol = MakeFontSymbol(Val(arrItems(2)), Val(arrItems(3)), Val(arrItems(4)), arrItems(5), Val(arrItems(6)), Val(arrItems(7)))


                  Case "3"

                        'Symbol value based on a bitmap file

                        STLText2Symbol = MakeCustomSymbol(arrItems(2), Val(arrItems(3)), Val(arrItems(4)), Val(arrItems(5)))

            End Case

      End If


      Exit Function



      Call ERRCreate(Err(), Error$(), "STLText2Symbol: " & sSymbol)

      Call ERRShow()

      STLText2Symbol = CurrentSymbol()


End Function


Find the MapBasicLib on Github.




Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer


From: <> On Behalf Of Marijan
Sent: Wednesday, 1 February 2023 11.14
To: MapInfo-L <>
Subject: [MI-L] Convert style definition to string [MapBasic]


This message originated Externally. Use proper judgement and caution with attachments, links, or responses.


You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to
To unsubscribe from this group, go to:
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at

You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Reply all
Reply to author
0 new messages