Forcing string comparisons, or When is "0" not 0?

Randy Hengst iowahengst at mac.com
Wed Oct 14 21:37:18 EDT 2015


Rather than write the IF statement with AND NOT I’ve just written separate IF statements… first, check the field for the “.” first… then in a separate “if” statement check the rest of your math… that seems pretty easy for a novice to understand. It also provided a way to show that when the if statement wasn’t met, nothing happened… 

I’d even write it like this:

  if char -1 of field "display" = "." then 
      delete char -1 of field "display"
   else
      -- do nothing
   end if



be well,
randy

Randy Hengst
www.classroomFocusedSoftware.com


> On Oct 14, 2015, at 4:10 PM, Devin Asay <devin_asay at byu.edu> wrote:
> 
> 
>> On Oct 14, 2015, at 2:39 PM, Paul Dupuis <paul at researchware.com> wrote:
>> 
>> if fld "Display" contains "." then
>> 
>> of if you're just concerned with it ending with "."
>> 
>> if fld "Display ends with ".” then
> 
> Yeah, that works, but then I end up with a mess like this:
> 
>  if fld “display” = 0 AND NOT fld “display” ends with “.” then … 
> 
> But this may be what I have to go with. That’s at least *sort of* comprehensible to a newbie.
> 
> I'll have to explain to them that “LiveCode tries its hardest to make something into a number if there is any chance at all that it could be a number, so we have to do an extra check to make sure it’s not this specific type of numeric expression that happens to end with a dot.”
> :-/
> 
> Devin
> 
> Devin Asay
> Office of Digital Humanities
> Brigham Young University
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list