Hi
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
sSym =
CurrentSymbol()
symNew = 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
'-------------------------
ErrorOccured:
Call ERRCreate(Err(), Error$(), "STLText2Symbol: " & sSymbol)
Call ERRShow()
STLText2Symbol = CurrentSymbol()
End Function
Find the MapBasicLib on Github.
From: mapi...@googlegroups.com <mapi...@googlegroups.com>
On Behalf Of Marijan
Sent: Wednesday, 1 February 2023 11.14
To: MapInfo-L <mapi...@googlegroups.com>
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 mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
---
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
mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/mapinfo-l/4b98de88-b5f5-41a2-ab7c-7b31ae081a62n%40googlegroups.com.