I have an expression in VBscript that works well for labeling:
Function FindLabel (field) if (INT(RIGHT(field, 2)) <> 1) then FindLabel = INT(MID(field, 8, 3)) &"-"& INT(RIGHT(field,2)) else FindLabel = INT(MID(field, 8, 3)) end if End Function
This expression labels a text in this format: VCC065-00102 to: 1-2 or from VCC065-00501 to: 5 (using just the last 5 carachters, if the last one is > 1, it shows the number after a "-").
But, when I tried to use the same script for calculating a field, I've got a syntax error error:
Code block: the same as above
Also, I tried to convert this script to Python:
def FindLabel (Field): Var1 = Field[-2:] Var2 = Field[8:-3] if (int(Var1) <> 1 ): FindLabel = int(Var2) &"-"& int(Var1) else: FindLabel = int(Var2)
But it returns an error: The field is not nullable. (I don't know why, but the expression is returning a null value)