Select to view content in your preferred language

Label Expression

3459
8
08-21-2015 06:53 AM
MikeFroese
Deactivated User

I have a simple label expression that I use for utility lines that give me size and material in a mapbook.

[diameter] +  "in "  +  [materialType]

I have values that are <Null>. Thru the label expression is there script that I can add to replace the <Null> with a question mark etc. I know I can just change the field, but would be nice to have the expression do it

Thanks

0 Kudos
8 Replies
WesMiller
Deactivated User

0 Kudos
MikeFroese
Deactivated User

Thanks for quick response.

My label expression box only shows Jscript and VBScript parsers. I have ArcMap 10 does that matter.

Sorry I am a GIS/CAD guy and don't know much about scripts.

Thanks

0 Kudos
WesMiller
Deactivated User

Mike Froese​ the syntax is different maybe someone else will chime in with the proper syntax

ChrisSmith7
Honored Contributor

Wes,

I had something similar, but ended-up using falsy logic on the null string check:

def FindLabel ( [NominalDiameter], [Material] ):
    ins, material, nd, q = ' in ', str([Material]), str([NominalDiameter]), '?'
    if not [Material]:
        label = ''.join([nd, ins, q])
    else:
        label = ''.join([nd, ins, material])
    return label
TedKowal
Honored Contributor

In Python? See Picture below   vbscript you would test for isNull

Null.png

MikeFroese
Deactivated User

Thanks for quick response.

Sorry I am a GIS/CAD guy and don't know much about scripts.

Is the fieldvalue a default name or do I put my values in. Plus what is FLG=

Mine comes up with either diameter= or materialtype=

Thanks

0 Kudos
TedKowal
Honored Contributor

One trick to format the field name correctly is to place your cursor where you want to insert the field then double click on the name of the field list in the box above.  The field name should be inserted properly formatted for the scripting language you are using.

Hope this make sense!

DarrenWiens2
MVP Honored Contributor

My field, called "NULLS", has some nulls and some values. Use IsNull() to test in VBScript:

Function FindLabel ( [NULLS] )
if IsNull([NULLS]) then
  label = "?"
else
  label = [NULLS]
end if
FindLabel = label
End Function