LiveCode Programming Support for Beginners?

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
fewchips
Posts: 1
Joined: Tue Apr 01, 2025 3:50 am
Contact:

LiveCode Programming Support for Beginners?

Post by fewchips » Tue Apr 01, 2025 3:52 am

Hi admin and everyone

I'm new to LiveCode and am having some trouble using basic commands to manipulate the user interface. Specifically, I want to create a simple application with a button to change the text in an input field. I tried using the set the text of field command but it didn't work. Can anyone explain how this command works and provide an example? Also, where can I find some documents or tutorials to learn LiveCode effectively?
Thank you everyone!

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

Re: LiveCode Programming Support for Beginners?

Post by Klaus » Tue Apr 01, 2025 9:12 am

Hello fewchips,

welcome to the forum!
Please tell us what exactly you have tried so far.

Basically you do this to
1. replace the complete text of a field: put "Your new text here..." into fld "your textfield"
2. replace a word in a field: put "Supercalifragilisticexpialidocious" into word 2 of fld"your textfield"
3. replace word 2 of the second line in a field: put "Supercalifragilisticexpialidocious" into word 2 OF LINE 2 of fld "your textfield"
4. replace a complete line in a field: put "this is the new line 2" into line 2 of fld"your textfield"
5. Add a line (and a line break = Carriage Return) at the end of your field: put CR & "This is the last line in my field" AFTER fld "your textfield"
etc.

Best
Klaus

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

Re: LiveCode Programming Support for Beginners?

Post by bogs » Tue Apr 01, 2025 1:17 pm

Klaus wrote:
Tue Apr 01, 2025 9:12 am
Please tell us what exactly you have tried so far.
Um...
fewchips wrote:
Tue Apr 01, 2025 3:52 am
I tried using the set the text of field command but it didn't work.
<chuckle>
As Klaus's examples demonstrate, "put" is the most commonly used to set the value of a variable, put text into a field, put data into a file, display text in the message box, or upload a file to a server. The dictionary lays out like this:
Lc Dictionary wrote: Use the put command to set the value of a variable, put text into a field, put data into a file, display text in the message box, or upload a file to a server.
Syntax:
put value [{before | into | after} container]
put value into URL destinationURL
Examples:
put "ABC"
put 3 + 12 into myVariable
put return someGlobalVar after field "Accumulations"
"set" is also very useful, but not for "setting" contents per se:
Lc Dictionary wrote: Use the set command to change the setting of a property or custom property.
Syntax:
set [the] property [of object] to value
Examples:
set the textFont of button "next" to "Arial"
set the cursor to watch
set the backgroundcolor of graphic "background" to green
fewchips wrote:
Tue Apr 01, 2025 3:52 am
Also, where can I find some documents or tutorials to learn LiveCode effectively?
The dictionary is quite helpful, if for instance you want to know about oh, say, changing things about a font, you can type in 'font' and it will locate information regardless of where it falls in the dictionary. The downside is that you will pull up any entry with font in it, so some skimming is necessary.

I don't know about the most current incarnations of Lc or whatever it is called these days, but from 9.6 backwards there is a user guide included which covers the most basic topics.

Also, again, past editions had a link to samples in the initial loading (resources) in the ide, and of course you can do a general search for Livecode tutorials, there are a few around.

Always of course, any question you have can be asked here and likely answered to death :twisted:
Image

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

Re: LiveCode Programming Support for Beginners?

Post by dunbarx » Tue Apr 01, 2025 2:57 pm

Hi.

There are many ways to do things in LiveCode.

For one, the text of a field is a property of that field, and so one can:

Code: Select all

set the text of field "yourFieldHere" to "Hello World"
So from a button script, you could either:

Code: Select all

on mouseUp
   ask "Enter New Text"
   put it into fld "yourFieldHere"
   -- or
   -- set the text of field "yourFieldHere" to it
end mouseUp
"It" is a special local variable in LC, so learn about, er, "it".

Your first instincts were therefore correct, you just had a syntax error. That is the good news; it is encouraging that you "knew" how to do it, but did not know exactly how.

Craig

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

Re: LiveCode Programming Support for Beginners?

Post by Klaus » Tue Apr 01, 2025 3:48 pm

I've moved this thread to the "Beginner" section.

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

Re: LiveCode Programming Support for Beginners?

Post by bogs » Thu Apr 03, 2025 8:49 pm

Good thing, as I have apparently been away from the language long enough to probably need to stay here :roll:
Image

Post Reply