How to write scripts for buttons to perform arithmetic operations
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 1
- Joined: Thu Feb 29, 2024 12:13 pm
- Contact:
How to write scripts for buttons to perform arithmetic operations
Hello LiveCode experts,
I am working on a project that involves creating a simple calculator app using LiveCode. I have followed the tutorial and managed to create a basic interface with buttons and fields. However, I am stuck on how to write the script for the buttons to perform the arithmetic operations. I have searched the LiveCode documentation and forums, but I could not find a clear example or explanation of how to do this.
How can I write a script for the calculator buttons to perform the addition, subtraction, multiplication, and division operations on the numbers entered in the fields? What are the LiveCode commands and syntax that I need to use? How can I handle errors such as dividing by zero or entering invalid input?
I would appreciate any help or guidance on how to solve this problem.
I am working on a project that involves creating a simple calculator app using LiveCode. I have followed the tutorial and managed to create a basic interface with buttons and fields. However, I am stuck on how to write the script for the buttons to perform the arithmetic operations. I have searched the LiveCode documentation and forums, but I could not find a clear example or explanation of how to do this.
How can I write a script for the calculator buttons to perform the addition, subtraction, multiplication, and division operations on the numbers entered in the fields? What are the LiveCode commands and syntax that I need to use? How can I handle errors such as dividing by zero or entering invalid input?
I would appreciate any help or guidance on how to solve this problem.
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: How to write scripts for buttons to perform arithmetic operations
I have a feeling that you should be doing some of the work.
Here is "something" to get you started (it involved about 10 minutes work, so do NOT expect anything very special):
-
Here is "something" to get you started (it involved about 10 minutes work, so do NOT expect anything very special):
-
- Attachments
-
- CALC START.livecode.zip
- (1.65 KiB) Downloaded 27 times
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: How to write scripts for buttons to perform arithmetic operations
Start with the supplied examples, and then start pooking around in the inbuilt Dictionary.LiveCode commands and syntax
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: How to write scripts for buttons to perform arithmetic operations
Traps an error if you try to divide something by zero:
-
-
- Attachments
-
- CALC START 2.livecode.zip
- (1.73 KiB) Downloaded 22 times
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: How to write scripts for buttons to perform arithmetic operations
Why do I feel that the OP might be a phantom?
-
- VIP Livecode Opensource Backer
- Posts: 9847
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: How to write scripts for buttons to perform arithmetic operations
I can't imagine how you could get that impression. It's been less than a day since he posted his question.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9726
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: How to write scripts for buttons to perform arithmetic operations
Richmond.
Your rate of posting has unsettled your expectations.
Craig
Your rate of posting has unsettled your expectations.
Craig