One more calculation question.......

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Rage
Posts: 12
Joined: Fri Mar 27, 2015 2:34 am

One more calculation question.......

Post by Rage » Fri Mar 27, 2015 2:42 pm

Any idea how this: mon = round((24-12)/10)

could throw an error as being a double binary operator?

The same happened with :mon is round((24-12)/10)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: One more calculation question.......

Post by dunbarx » Fri Mar 27, 2015 2:59 pm

Hi.

Not sure quite how you are forming your code, that is, how you are translating into proper LC syntax. The following works fine:

Code: Select all

  answer round((24-12)/10)
or:

Code: Select all

  put round((24-12)/10) into mon
How are you implementing this sort of thing?

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: One more calculation question.......

Post by FourthWorld » Fri Mar 27, 2015 4:19 pm

Craig's got it. In many other languages "=" is an assignment operator, resulting in millions of lost hours every year hunting down bugs related to the difference between "=" and "==" (it's sometimes fun to surf the Web with your browser's console open <g>).

LiveCode is immune to that particular productivity loss. :)

In LC "=" and its synonym "is" are always comparison operators, with assignment done using the "put" command.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Rage
Posts: 12
Joined: Fri Mar 27, 2015 2:34 am

Re: One more calculation question.......

Post by Rage » Fri Mar 27, 2015 4:20 pm

Interestingly enough the second example you gave worked fine.
I'm trying to convert the system date to the Julian equivalent and for the most part seem to be getting
caught up on the syntax of the scripting language and finding work arounds for syntax not native to livecode.

Which is the major part of learning any new language of course...........

Is there some direction that might point to the proper syntax for programming livecode other than the documentation as
it seems a bit ambiguous.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: One more calculation question.......

Post by dunbarx » Fri Mar 27, 2015 5:24 pm

It takes effort and time. LC seems so accessible that you might think you could learn how to drive in a few hours. It is indeed accessible, but it is also large and rich. The User Guide is a great start, the lessons are good, the dictionary is terrific, and there are other resources, like:

http://www.hyperactivesw.com/revscriptc ... ences.html

And there is this forum. You have to practice. You likely know this.

Craig

Rage
Posts: 12
Joined: Fri Mar 27, 2015 2:34 am

Re: One more calculation question.......

Post by Rage » Fri Mar 27, 2015 6:12 pm

Thanks Craig, I've downloaded them and no doubt refer to them often.......

again Thanks

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: One more calculation question.......

Post by FourthWorld » Fri Mar 27, 2015 6:25 pm

Rage wrote:Is there some direction that might point to the proper syntax for programming livecode other than the documentation as
it seems a bit ambiguous.
The Dictionary may seem ambiguous because it's a reference guide for specific syntax, and doesn't attempt to describe the overall flavor and flow of the language.

For that check out the User Guide, accessible from the Help menu. Chapter 5 provides a very good introduction to the language.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply