On 01/03/2016 20:44, Stephen MacLean wrote:
Hi All,

I’m looking for some help on complex statements in LCB.

I’m trying to take a script statement like this:

if (char x of tCardNum)*2 > 9 then

Hi Stephen,

Don't forget that LCB is strongly typed. That means that a string isn't a number, so you can't multiply it!

The expression "char x of tCardNum" evaluates to a string that's one character long. If "tCardNum" has fewer than "x" characters, then it throws an error.

If the character is expected to be the string representation of a number, then you probably want to explicitly convert it to a number:

   variable tNum as Number
   put (char x of tCardNum) parsed as number into tNum
   if 9 < 2 * tNum then
      ...
   end if

                                           Peter


--
Dr Peter Brett <peter.br...@livecode.com>
LiveCode Open Source Team

LiveCode 2016 Conference https://livecode.com/edinburgh-2016/

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to