Hi Ryan
I can't put my finger on why your code fails. The error you get is meant to tell you that you can't use a theme on that layer. I got the same error when my layer referred to 0.
I create a small sample code to reproduce your case but it doesn't fail for me.
The code is only for testing the Set Shade but it can also create a new theme to prepare the map for testing. In the first run, you pick Shade when asked and now you can pick Set Shade when you run it again. The code just changes the theme to use the column LATITUDE instead of LONGITUDE.
Include "MapBasic.def"
Include "Defines.def"
Declare Sub Main
Sub Main
Dim nMID, nLayoutID, nLayerID As Integer,
sTab, sCol As String,
bFnd, bShade As Logical,
arrRanges() As Float,
arrSymbols() As Symbol
sTab = "Bank_Branches"
nLayoutID = FrontWindow()
nMapLayoutID = LayoutItemWinID(nLayoutID, "Main Map", LAYOUT_ITEM_TYPE_MAPPER)
bShade = Ask("Shade or Set Shade?", "Shade", "Set Shade")
If bShade Then
Create Ranges
From sTab
With LONGITUDE
Use "Natural Break"
Number 5
Into Variable arrRanges
Else
Create Ranges
From sTab
With LATITUDE
Use "Natural Break"
Number 5
Into Variable arrRanges
End If
Create Styles
From Symbol MakeFontSymbol(57,RED,10,"MapInfo Symbols",0,0) 'style for LOW range,
To Symbol MakeFontSymbol(57,BLUE,10,"MapInfo Symbols",0,0) 'style for HIGH range
Vary Color By "RGB"
Number 5
Into Variable arrSymbols
bFnd = FALSE
For nLayerID = 1 To MapperInfo(nMapLayoutID, MAPPER_INFO_LAYERS)
If LayerInfo(nMapLayoutID, nLayerID, LAYER_INFO_NAME) = sTab Then
bFnd = TRUE
Exit For
End If
Next
If Not bFnd Then
Note "Layer '" & sTab & "' not found!"
Exit Sub
End If
If bShade Then
Shade Window nMapLayoutID
nLayerID
with LONGITUDE
Ranges From Variable arrRanges
Style Variable arrSymbols
Else
nLayerID = nLayerID - 1
Set Shade Window nMapLayoutID
nLayerID
with LATITUDE
Ranges From Variable arrRanges
Style Variable arrSymbols
End If
End Sub
Here is my sample map in my layout after I created the initial theme with the Shade statement.
And here is the map after I modified the theme with the Set Shade statement.
------------------------------
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data
------------------------------