Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I trying to return three field values in same If Statment and conecate them, but i Get NULL value insted of the conecated fields

 getClass (!InDiameter! , !OutDiameter! , !TheridDiameter!, !FREQUENCY! )
     if FREQUENCY== 1:
        return In
     if FREQUENCY== 2:
        return(In &"-"& Out)

     if FREQUENCY == 3:
        return(In &"-"& Out &"-"&Therid)

enter image description here

share|improve this question

1 Answer 1

up vote 5 down vote accepted
getClass (In , Out , Therid, freq )
     if FREQUENCY== 1:
        return str(In)
     elif FREQUENCY== 2:
        return (str(In) + "-" + str(Out) )
     elif FREQUENCY == 3:
        return (str(In) +"-" + str(Out) + "-" + str(Therid) )
     else:
        return "other frequency" 

here is a quick fix. Concantenation in Python uses "+", and I converted your fields to string str() just to make sure they are not numeric (otherwise not necessary)

share|improve this answer
    
In the input parameters, you need to define frequency the same as in the rest of the code; FREQUENCY (or change in the code to freq). –  Martin Mar 20 at 9:24
    
it's work but i get zero's (3.0 insted of 3) because i put str for double value –  mahmoud hageer Mar 20 at 9:48
1  
you can use str(int(In)) in place of str(In) –  radouxju Mar 20 at 10:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.