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);
Zip5 := LeftStr(edtZip.Text + ' ', 5);
if (Zip5 = ' ') then
ShowMessageApp('You must provide a Zipcode to use this function.')
else
AliasForm.GetAliasesForZipcode(Zip5);
And if you could, it might hurt.
ReplyDeletesome 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)
ReplyDeleteMight 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 ''.
ReplyDeleteStefan -- trust me, it's the latter. ;-)
ReplyDeleteCould be worse!
ReplyDeleteZip5 :=Trim( LeftStr(edtZip.Text + ' ', 5));
...
well, if the zipcode has a fixed length (what I presume) then the comparison with '' would be better, in fact.
ReplyDeleteI 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)