I'm having a hard time coming up with the thought pattern that brought this about:

I'm having a hard time coming up with the thought pattern that brought this about:

     Zip5 := LeftStr(edtZip.Text + '     ', 5);
      if (Zip5 = '     ') then
        ShowMessageApp('You must provide a Zipcode to use this function.')
      else
        AliasForm.GetAliasesForZipcode(Zip5);

Comments

  1. some people deserve to die very slowly... reading their own code in an endless loop until true=false! (some clever idiot defined some variables with that names long ago, was a nightmare to debug and found the error)

    ReplyDelete
  2. Might be the GetAliasesForZipcode that needs 5 chars. So if you type in 42 it passes '42   ' (three spaces). If that's not the case this code is broken. Otherwise you could just Trim(edtZip.Text) and compare to ''.

    ReplyDelete
  3. Stefan -- trust me, it's the latter.  ;-)

    ReplyDelete
  4. Could be worse!

     Zip5 :=Trim( LeftStr(edtZip.Text + '     ', 5));
    ...

    ReplyDelete
  5. well, if the zipcode has a fixed length (what I presume) then the comparison with '' would be better, in fact.
    I wrote somewhere if (s+' ')[1] = 'L' to be sure that this comparison with the string with variable length will not crash. (BUt yes, ther would have been other ways to achieve a secure behaviour)

    ReplyDelete

Post a Comment