I am trying to use a find label expression that changes the font of one field, [NUMBERNAME]
. I am using the Python parser of ArcGIS 10.3.1 for Desktop.
All fields have a data type of text. This is what I have...
def FindLabel ([NUMBERNAME]):
lineone = "A:"+ [NUMBER]
absName = "<CLR red='255'><FNT size = '14'>" + [NUMBERNAME] + "</FNT></CLR>"
if [NUMBERNAME] != None:
return lineone + '\n' + absName + '\n' + "BLK:" + [BLOCK] + '\n' + "SEC:"+ [SURNUM]
I am getting an error. Any thoughts as to what is wrong?
Error:
The expression contains an error. Modify the expression and try again. Error 0 on line 0. SyntaxError: invalid syntax(string, line 2).
enter image description here
2 Answers 2
You currently have:
lineone = "A:" + [NUMBER]
but [NUMBER]
isn't defined anywhere.
Any fields that you want to use in the expression, you need to include as a parameter to the function.
So, it looks like you would want:
def FindLabel ([NUMBERNAME], [NUMBER], [BLOCK], [SURNUM]):
...
You need to allow for [NUMBER], [BLOCK], and [SURNUM] in your function.
def FindLabel([NUMBERNAME],[NUMBER],[BLOCK],[SURNUM]):
And make sure to account for None
to be returned if any of those fields could be empty.
Explore related questions
See similar questions with these tags.
.format()
:"{0}\n{1}\nBLK:{2}\nSEC:{3}".format(absName, [BLOCK], [SURNUM])