LiveCode Programming Support for Beginners?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
LiveCode Programming Support for Beginners?
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!
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!
Re: LiveCode Programming Support for Beginners?
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
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
Re: LiveCode Programming Support for Beginners?
Um...
<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:
"set" is also very useful, but not for "setting" contents per se: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"
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
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


Re: LiveCode Programming Support for Beginners?
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:
So from a button script, you could either:
"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
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"
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
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
Re: LiveCode Programming Support for Beginners?
I've moved this thread to the "Beginner" section.
Re: LiveCode Programming Support for Beginners?
Good thing, as I have apparently been away from the language long enough to probably need to stay here 

