How to get started with LiveCode for beginners?

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Re: How to get started with LiveCode for beginners?

Post by FourthWorld » Wed Dec 11, 2024 8:15 pm

Back on topic:
nearlyattach wrote:
Tue Dec 10, 2024 6:10 am
Hi everyone,

I am new to LiveCode and would like to know the most effective way to learn. Are there any resources or tutorials for beginners?
Many. Arguably, too many to absorb all at once. So let's break it down.

First, the User Guide included in the LC install (see the Help menu) is comprehensive. So much so I don't recommend reading all of it before playing. Playing is more fun. Let's shorten the path to the fun.

Skim the User Guide so you have a sense of what's in there, but don't bother actually reading much more than the first few chapters to get oriented to using objects, their properties, and their scripts.

Then take a breath and remember how vast the universe of software is, and that you can spend your life studying it and barely scratch the surface, so moving forward in focused chunks of learning often works very well.

So after you've skimmed the User Guide and taken a breath, come back here and tell us more about the types of apps you want to make. What do they do, how do they fit into the user's life?

With your initial orientation to LC in the User Guide, and our subsequent orientation to your goals, we can then suggest specific areas of study, and good exercises to build and reinforce mastery in those areas.

--

And yes, I promised play, so let's play:

1. Make a new stack from the File menu.

2. Drop three fields onto the card.

3. Drop a button onto the card, and right-click it to open it's script, where you'll paste this into it:

Code: Select all

on mouseUp
  put field 1 + field 2 into field 3
end mouseUp
4. Choose the Browse tool, and type a number into each of the first two fields.

5. Click the button.

Boom. You just made a simple calculator.

Later on you'll learn about handling user input errors, like what happens if they type a letter into either of the first two fields (try it), and then there's standalone building, and much more.

But I think fun is the highest priority, so at least this simple exercise gives you a working result in just a minute or two.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: How to get started with LiveCode for beginners?

Post by dunbarx » Wed Dec 11, 2024 9:44 pm

Richard.

Boom?

Oh, you meant "Bang".

Craig

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

Re: How to get started with LiveCode for beginners?

Post by bogs » Tue Dec 24, 2024 12:50 pm

FourthWorld wrote:
Wed Dec 11, 2024 8:15 pm
1. Make a new stack from the File menu.
2. Drop three fields onto the card.
3. Drop a button onto the card, and right-click it to open it's script, where you'll paste this into it:

Code: Select all

on mouseUp
  put field 1 + field 2 into field 3
end mouseUp
4. Choose the Browse tool, and type a number into each of the first two fields.
5. Click the button.

Boom. You just made a simple calculator.
Oddly enough, the end product you demonstrate was an early experiment I did.
Not to sound too 'picky', but that isn't a calculator. It is more closely aligned to an old adding machine (no other math function(s) available).

However, it isn't too far off of the solution I eventually struck, also simple, quick to knock together, etc.

The interface :
InlineCalcInterface.png
Inline Calculator...
The code is certainly more involved than simple addition (but not a lot more), and does some amount of testing for correct information < an invaluable lesson to learn, the random things user's will enter really needs to be heavily monitored >. Having said that, here is the code :

Code: Select all

/* this code is residing in the card level,
 however, it could just as suitably be placed
  in the first field's script, or anywhere along
  the path from there down to the stack level...*/

local theCharacters # variable to hold the input of field 1 for testing...

on openCard
   put "" into field 1 # prepares the field for entry by emptying it...
   put "" into field 2
   put "1234567890*/+-()" into theCharacters # these are the characters I'm testing for...
   set the hilited of button "rdoAnswer" to true # this relates to the copying of the answer or the problem + answer, and is optional...
end openCard

on textChanged
/* here I want to validate the text entered as soon
 as it was entered, instead of making the user wait 
 to know they need to change something...*/
 
   repeat for each character x in field 1
      if x is not in theCharacters then 
         answer "Sorry, you have used something other than a number or operation symbol." & cr & "Please correct the statement."
         exit to top # if the character is not a number or math function, exit the routine...
      end if
   end repeat
end textChanged

on returnInField
   put the value of field 1 into field 2
end returnInField

/* I want the problem solved and placed
 in the answer box regardless of whether
  the user presses the [Enter] or [Return] keys,
   most lay people don't know there is even a difference...*/
   
on enterInField
   put the value of field 1 into field 2
end enterInField
More involved ? Certainly. Overly involved? Depends. I would say this is close to the bare minimum for an approximation of an actual calculator (knowing of course that someone with more knowledge probably has done a one liner version :P ) and should be approachable to a beginner.
Image

Post Reply