Trying a custom handler for several math fields

dunbarx at aol.com dunbarx at aol.com
Fri Sep 13 09:18:58 EDT 2013



Vaughn.


YOU WERE A HC USER??!!??


Sorry. Ahem.


But then you must remember that you cannot add "$50" to "15". xTalks are typeless, and the parser resolves strings into usable form purely by context. So you can only add strings that resolve to numbers.


Would this be immediately understandable to you?:


function goodNumber tText --valid in both HC and LC
   repeat with y = 1 to the number of chars of tText
      if char y of tText is in ".0123456789" then put char y of tText after temp
   end repeat
   return temp
end goodNumber


In LC, we have another way to do it:


function goodNumber tText --valid in LC only
   repeat for each char tChar in tText
      if tChar is in ".0123456789" then put tChar after temp
   end repeat
   return temp
end goodNumber


This last is faster; LC is a superset of HC. But you must already have a huge head start in all this. It is just a matter of learning new language elements, unlearning such things as backgrounds in lieu of groups, and so forth. An effort, to be sure, but I retract my wager. You already have won, though it appears you do not yet know it.


Were you part of the HC community 15 years or so ago? The LC one is larger, comprised of many of the same (now older) members, and growing. Thank heaven.


Craig

 



More information about the use-livecode mailing list