Having trouble creating functions for scientific calculator

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
qqchrono
Posts: 13
Joined: Tue Oct 24, 2017 3:27 am

Having trouble creating functions for scientific calculator

Post by qqchrono » Tue Nov 21, 2017 5:23 am

Hello!

I got tasked recently to create a calculator which i have managed to create a standard one with a few basic functions... The problem comes when i tried to escalate it into a scientific calculator which is actually just adding tan,cos,sin,tan-1,cos-1,sin-1 functions (I know that's not all to a scientific calculator haha but this'll suffice). Been stuck at these functions for awhile now.
Coming from a weak maths background i tried prowling the internet for information on the formulas but could not find one with a formula that could explain it in a way i understand. Could anyone offer any input or help on this?

Thanks!

Chrono
Attachments
Scientific calculator.zip
(1.5 KiB) Downloaded 168 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Having trouble creating functions for scientific calculator

Post by richmond62 » Tue Nov 21, 2017 11:12 am

As tan, sine, cosine and so forth are built into LiveCode
people like You and I can "cheat", and not get all worried about the shame
of being bad at Maths at school.

Make the Dictionary your friend 8)
sine.png

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Having trouble creating functions for scientific calculator

Post by bogs » Tue Nov 21, 2017 2:20 pm

richmond62 wrote:
Tue Nov 21, 2017 11:12 am
Make the Dictionary your friend 8)
It doesn't even have to be the stock dictionary, you can make any of these your new best buddy !

*Brian's page is actually the stock dictionary, just much much _-`faster.
Image

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Having trouble creating functions for scientific calculator

Post by [-hh] » Tue Nov 21, 2017 2:46 pm

Here is one (by MaxV). Has more features than you need.
http://livecodeshare.runrev.com/stack/7 ... Calculator
shiftLock happens

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Having trouble creating functions for scientific calculator

Post by dunbarx » Tue Nov 21, 2017 3:00 pm

Hi.

As Richmond said, all the functions you mentioned are native to LC. So my question to you is this: Did you just not know that, or are you having difficulty implementing them?

In other words, and never mind how the user interface might work, are you able to simply:

Code: Select all

on mouseup
ask "Enter angle"
if it is a number then answer sin(it)
end mouseUp
And do you know that the arguments to trig functions are in radians?

Craig Newman

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Having trouble creating functions for scientific calculator

Post by richmond62 » Tue Nov 21, 2017 7:27 pm

And do you know that the arguments to trig functions are in radians?
That's stated explicitly in the dictionary.
plonk.jpg
plonk.jpg (9.12 KiB) Viewed 5935 times

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Having trouble creating functions for scientific calculator

Post by [-hh] » Tue Nov 21, 2017 7:28 pm

dunbarx wrote:And do you know that the arguments to trig functions are in radians?
Yes, I know. And I even know what radians are ;-)
shiftLock happens

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Having trouble creating functions for scientific calculator

Post by dunbarx » Tue Nov 21, 2017 9:01 pm

Ah.

Hermann is back. :)

qqchrono
Posts: 13
Joined: Tue Oct 24, 2017 3:27 am

Re: Having trouble creating functions for scientific calculator

Post by qqchrono » Thu Nov 23, 2017 1:50 am

richmond62 wrote:
Tue Nov 21, 2017 11:12 am
As tan, sine, cosine and so forth are built into LiveCode
people like You and I can "cheat", and not get all worried about the shame
of being bad at Maths at school.

Make the Dictionary your friend 8)

sine.png
Oh thats weird the first time i checked i only found atan, asin, acos which i have no idea what they meant. I tried looking it up in the dictionary before because i used sqrt for the calculator. :shock:

Thanks for pointing that out, will look through again.

qqchrono
Posts: 13
Joined: Tue Oct 24, 2017 3:27 am

Re: Having trouble creating functions for scientific calculator

Post by qqchrono » Thu Nov 23, 2017 1:54 am

dunbarx wrote:
Tue Nov 21, 2017 3:00 pm
Hi.

As Richmond said, all the functions you mentioned are native to LC. So my question to you is this: Did you just not know that, or are you having difficulty implementing them?

In other words, and never mind how the user interface might work, are you able to simply:

Code: Select all

on mouseup
ask "Enter angle"
if it is a number then answer sin(it)
end mouseUp
And do you know that the arguments to trig functions are in radians?

Craig Newman
Yes i would be able to code it. My mistake i missed the function out completely :?

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”