Geographic Information Systems Asked by SlagMuffin on February 27, 2021
I’m trying to write a bit of code that looks the columns of a table and if they match by text, then generate a thematic of predefined ranges.
So far:
Include "MapBasic.def"
Declare Sub Main
Sub Main()
Dim ColumnCount as integer
Dim ColumnName as string
Dim TableName as string
Dim aColAlias as Alias
Dim WinID as integer
WinID = FrontWindow()
TableName = tableinfo(1,TAB_INFO_NAME)
'Assume table 1 for this test
for ColumnCount=1 to tableinfo(1,TAB_INFO_NCOLS)
ColumnName = ColumnInfo(1,"COL" & ColumnCount,COL_INFO_NAME)
if instr(1,ColumnName,"RSRQ") >1 and instr(1,ColumnName,"SS") > 1 then
print TableName & "." & ColumnName 'works as expected
aColAlias = ColumnName
'Create Thematic
Shade Window WinID TableName with aColAlias
ignore 0
Ranges
-1 : -4 Symbol(108,6750207,10,"Wingdings",0,0),
-4 : -7 Symbol(108,8454016,10,"Wingdings",0,0),
-7 : -10 Symbol(108, YELLOW,10,"Wingdings",0,0),
-10 : -13 Symbol(108,16757529,10,"Wingdings",0,0),
-13 : -60 Symbol(108,RED,10,"Wingdings",0,0)
exit For
End If
Next
End Sub
The Shade command always fails with ‘Invalid variable Type’
I’ve tried replacing the Column Alias with the string of the column name, but that doesn’t work either. I’m sure its something simple, but I just can’t see it.
Solved! It turns out that if the column doesn't have any values in it, this error will occur. So check for no values first.
Answered by SlagMuffin on February 27, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP