Total newb question: selecting from a list

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
cliffale7
Posts: 6
Joined: Mon Apr 04, 2016 9:58 pm

Total newb question: selecting from a list

Post by cliffale7 » Mon Apr 04, 2016 10:09 pm

I am a complete and total newb so honestly, if you explain it like you're talking to a baby I'll be more grateful than offended. Lol.

I'm going to try to make an app that will display a random quote in the morning and again in the evening. Each displayed quote will come from a list of quotes that are relevant to the time of day (a separate collection of quotes for morning and evening).

When I'm creating or adding to the list of quotes for the app to draw from, what part of LiveCode am I storing it to? Do I create a card with a list on it to use? And add the quotes to the list? I'm just learning programming and I'm using LiveCode to do it but while I'm learning the how's of creating the app itself, I'd like to know where I can at least be adding the quotes to use as I'm inspired to write them so that I can use them once I get that far in my learning.

If that makes sense.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Total newb question: selecting from a list

Post by dunbarx » Mon Apr 04, 2016 11:23 pm

Hi.

You could not have chosen a better platform to do this. You will have a ball. But you must, while you are fooling around with this quote gadget, get going with the usual learning tools:

The User Guide that comes with LC, and keep the dictionary handy. And:

http://www.hyperactivesw.com/revscriptc ... ences.html

That said, projects are usually laid out mentally, something like:

1- Store my quotes somewhere.
2- Run a clock of some sort
3- If the time is something of interest, display a random quote in some fashion.

and also

4- Be able to modify my quote library.

Easy.

But you need to learn how to drive. So can you make a stack? Put controls on a card? Open the script editor and write a handler? Please let us know.

The good news is that it only takes a few weeks of learning and practicing to get to a level where you can do this type of project on your own. The other good news is that this forum is chock full of helpers who race to answer your questions. We are childish that way. The other other good news is that programming in LC is a gas.

So, where are you with LC exactly? Though simple and fun, there is a very large vocabulary (though for this project, you likely need only a dozen or two words) and a minimum of foundational knowledge that you must have in order to take control on your own. There is no short cut for this. But you can build as you go. Profanity derived from frustration should be kept to yourself; come to us after about ten minutes of that.

Craig Newman

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

Re: Total newb question: selecting from a list

Post by Simon » Mon Apr 04, 2016 11:34 pm

Hi cliffale7,
While this lesson isn't exactly what you are asking for
http://lessons.livecode.com/m/2592/l/21 ... xt-strings
it does uses random selection ("any") and text storage.
Shouldn't be too difficult to work from the lesson and get your desired app.

Ah, it uses "word" a whole bunch. You can replace that with "line"... you'll see.

Simon
PS. You only beat me by a minute Craig... Next time... :)
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Total newb question: selecting from a list

Post by dunbarx » Mon Apr 04, 2016 11:45 pm

Simon.

Shhh.

We have a newbie here. He mustn't get the wrong impression.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Total newb question: selecting from a list

Post by dunbarx » Mon Apr 04, 2016 11:49 pm

cliffale7.

What simon means is something like this. In a button script:

Code: Select all

on mouseUp
put any word of "The quick brown fox jumps over the lazy dog" into message box
end mouseup
Click the button a few times.

Craig

cliffale7
Posts: 6
Joined: Mon Apr 04, 2016 9:58 pm

Re: Total newb question: selecting from a list

Post by cliffale7 » Tue Apr 05, 2016 12:40 am

:lol: You guys are fantastic. My level is absolutely beginner. I'm going through a few tutorials: the Hour of Code and the one from Make Things Work and I'm learning about placement of the various objects, a very light introduction to storing input and repeating the strings (Answer function, I think?) and I'm completely mesmerized at seeing something I'm affecting and designing become a program. :) I'm very excited about the whole thing.

And I deeply appreciate the examples and resources you guys gave. I'll be digging through them tonight.

I'm basically toying around with my own app on the side expecting to implement ideas and functionality in it as I learn them throughout the tutorials and things. So I was basically looking for a model to learn from as my side project. :) Again, thanks so much for the directions you've given me.

cliffale7
Posts: 6
Joined: Mon Apr 04, 2016 9:58 pm

Re: Total newb question: selecting from a list

Post by cliffale7 » Tue Apr 05, 2016 12:50 am

Craig and Simon: another thing that blows me away is how much of a "human experience" it is to write code in LiveView. I don't have any real programming experience but just looking at code written in java for example... it's just so much more intuitive feeling with LiveCode. Using the example from above? The line that selects a random word from a sentence to display? It's just basically "telling" the computer what to do. It's pretty exhilarating, no? Lol.

And yes, I know how green I must sound. :D

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

Re: Total newb question: selecting from a list

Post by Simon » Tue Apr 05, 2016 1:00 am

It's just basically "telling" the computer what to do.
Always keep that in mind!
With the "English language like language" it is easy to just think of what you are trying to do and then check the Dictionary (your new best friend) it holds lots of hints to get to where you want to be.

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9785
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Total newb question: selecting from a list

Post by dunbarx » Tue Apr 05, 2016 1:07 am

Hi.

The penalty one pays for the privilege of a high-level english-like intuitive language like LC's is speed. Why, the handler:

Code: Select all

on mouseUp
   put the ticks into startTime
   put "XYZ" into temp
   repeat 10000000
      put temp into someVariable
   end repeat
   answer the ticks - startTime
end mouseUp
only gives me 5,000,000 interations per second. Granted, this process doesn't do much of anything useful. :D

Craig

TerryL
Posts: 78
Joined: Sat Nov 23, 2013 8:57 pm

Re: Total newb question: selecting from a list

Post by TerryL » Wed Apr 06, 2016 9:17 pm

Hi Cliffale7. You're going to have so much fun. Attached is a stack to help you get started on a path toward your project. Look inside the button and field objects (right Edit Tool arrow to select object, Object > Object Inspector and Object > Object Script). The object inspector, object script, card script, and stack script are where you write code that make the stack work. Dictionary (Help > Dictionary) is the most important resource for writing that code.

What could the empty field be used for? You might notice the same line being randomly chosen a few button clicks in a row. To be truly random, each line should be chosen from the list only once, until all lines have been chosen. One way to do that is with a master list and a duplicate work list. As lines are chosen, they're deleted from the work list until empty, then reloaded from the master list. Give that a try. Hint: put, delete line, if...then...else. Terry
Attachments
RandomLines.zip
(1.41 KiB) Downloaded 179 times
Beginner Lab (LiveCode tutorial) and StarterKit (my public stacks)
https://tlittle72.neocities.org/info.html

theotherbassist
Posts: 115
Joined: Thu Mar 06, 2014 9:29 am
Location: UK

Re: Total newb question: selecting from a list

Post by theotherbassist » Fri Apr 08, 2016 12:04 am

It's just basically "telling" the computer what to do. It's pretty exhilarating, no?
Be careful. Livecode is known to trick you into spending hours learning how to tell the computer what to do. It's almost like the computer told you to do that. Wait, who's in control?

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”