Spreadsheet like calculations

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
alexransome
Posts: 13
Joined: Fri May 17, 2013 9:32 am

Spreadsheet like calculations

Post by alexransome » Tue Sep 17, 2013 10:53 am

Hi,

I have started to learn Livecode and am getting real excited about it, but I feel that I need to have a project I can think about developing whilst I learn Livecode.

I have an idea for an app which is like a spreadsheet in that it has text boxes for cells and like a spreadsheet some text boxes will have text that the user has entered and some will display a result based on a calculation that uses a text box or uses a fixed value, or may even use a figure derived from the internet (but that will be later on).

Can Livecode handle this sort of thing, I'm sure it can but where will I need to be looking?

Thanks for any responses.

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

Re: Spreadsheet like calculations

Post by dunbarx » Tue Sep 17, 2013 1:57 pm

Welcome to paradise.

LC can certainly handle this, and it is the best possible way to learn. In fact, your project is ambitious. I usually recommend an address book or calculator. LC could create a stack that works exactly like Excel, but why reinvent the wheel?

That said, you will need to learn about messages and how they are generated and trapped. You may be familiar with how a "mouseUp" message is generated when you click on an object like a button, and that is pretty easy to grasp. You will now need to consider how clicking in a field, changing the contents of that field, exiting that field, and other actions also generate messages that need to be trapped and handled.

Look up the "textChanged", "openField, "closeField", "keyDown", 'ReturnInField" and "tabKey" messages. Also the "clickText" function and its relatives. Also look up all the "see also" suggestions in each of those. Oh, and there are many other related language elements that will be useful for you.

Write back when you get stuck. The community here races to answer your questions.

Craig Newman

alexransome
Posts: 13
Joined: Fri May 17, 2013 9:32 am

Re: Spreadsheet like calculations

Post by alexransome » Tue Sep 17, 2013 6:08 pm

Thanks for the reply.

I'm not wanting to remake excel. Just replicate these two formulas ...

=sum(((C7+C3-(C4+C5))/C1))*100

=sum((C3-(C4+C5))/D2)

Cheers.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Spreadsheet like calculations

Post by Simon » Tue Sep 17, 2013 6:28 pm

Hi alexransome,
This is easy in liveCode.
To keep things simple name your fields the same as your cells:

Code: Select all

on mouseUp
   answer (((field "C7"+ field "C3"-(field "C4"+ field "C5"))/ field "C1"))*100
end mouseUp
That should do it :)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Spreadsheet like calculations

Post by Klaus » Tue Sep 17, 2013 6:47 pm

Hi Alex,

no need to even reinvent the wheel in Livecode, look at this fine and free library:
http://www.tapirsoft.com/#!rgrid/mainPage :D

And check the rest of the website, too!


Best

Klaus

Post Reply