#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    6
    Rep Power
    0

    If statement evaluation problem


    In the If statement below, the criteria always evaluates to false in running code. If I paste the criteria in the immediate window and hit enter, it evaluates to true. The Coils object is an ADODB recordset connected to a DB/2 database (i think...its our AS400 Business system). I've also tried float(u'10') on the right side of the operator, but that doesn't work either (in the running code. any of this works in the immediate window). Any ideas on whats wrong?

    Code:
    if (float(self.Coils.Fields("csbfnb").Value) >= float(10)):
          self.Inventory.Fields("width").Value = float(self.Coils.Fields("csb6nr").Value)
    else:                            
          self.Inventory.Fields("width").Value = float(self.Coils.Fields("csbfnb").Value)
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    6
    Rep Power
    0
    Nevermind. I'm not sure what I was doing wrong before, but if i put float(u'10') on the right side, it works.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    Instead of float(10) or float(u'10') you could just use 10.0.

    However, are you sure the type of Coils.Fields("csbfnb").Value is a float? If it was a string, the comparision would still work, but a string always compares as greater than a float.

    Dave - The Developers' Coach

IMN logo majestic logo threadwatch logo seochat tools logo