Page 1 of 1
button makes form open
Posted: Fri Mar 21, 2014 10:47 am
by ledrac
I want to create an app that tracks my plants in my garden. I want to open the app select a button called new plant and have a window open that allows me to enter the new plants info and track it through its growth and chart the data. I have created a mainstack with cards representing my start card and my new plant card. How do i tell the button to open the new plant card?
Re: button makes form open
Posted: Fri Mar 21, 2014 10:51 am
by dave.kilroy
Hi Ledrac and welcome to the forum
Try this in the script of your button:
Code: Select all
on mouseup
go card "cdNewPlant"
end mouseup
Re: button makes form open
Posted: Fri Mar 21, 2014 1:06 pm
by Klaus
Hi ledrac,
you might want to take a look at these stacks, great learning resources:
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
Re: button makes form open
Posted: Sat Mar 22, 2014 8:10 am
by ledrac
I tried this code from the "Stock" lesson
on newEntry
## Add a new card
## This will create a new card with the controls group on it
create card
## The long name is a unique identifier
put the long name of it into tNewCard
## Put the initial text into the fields
send "resetControls" to group "controls" of tNewCard
## Go to the new card using a visual effect
visual effect push left
go to tNewCard
## Put the cursor in the name field
focus on field "name" of group "controls" of tNewCard
select after field "name" of group "controls" of tNewCard
end newEntry
How does the script know what new card to make? I don't want a copy of the card the button was on. I want it to use a blank form for each new plant.
Re: button makes form open
Posted: Sat Mar 22, 2014 8:19 am
by Simon
Hi ledrac,
Take a look at "template" in the dictionary.
Specifically templateCard
Simon
Re: button makes form open
Posted: Sat Mar 22, 2014 9:16 am
by ledrac
Thanks Simon. I am sorry for the silly questions but could you give me an example of how I would use the Template card in my app?
Re: button makes form open
Posted: Sat Mar 22, 2014 10:00 am
by Simon
Hi ledrac,
Not a silly question.
But, you should study the link Klaus posted and;
http://lessons.runrev.com/
In liveCode there are a dozen different ways to accomplish what you are trying to do and because of what it is you want to do I wouldn't recommend creating a new card.
Your project is great for learning liveCode but you slightly jumped in at the deep end. I guess one of the things I say quite often is that a standalone cannot save itself. In the IDE (where you write the scripts) sure, but not when you make a app (.exe,app).
No application ever saves itself, what it does is writes reminders in a separate file and reads that file every time it opens. Make sense? Every time you seem to have changed an app (like added bookmarks to a browser or changed a background color, setup an email account) it is written to a separate file.
Can you get your head around that? If it were me there would only ever be 2 cards in your stack (maybe 3).
Ugh;
http://lessons.runrev.com/s/lessons/m/4 ... ng-to-file
Not very helpful.
Study a bit and ask when you get stuck.
Simon
Re: button makes form open
Posted: Sat Mar 22, 2014 10:47 am
by ledrac
Thanks, it does make sense. I will study
Re: button makes form open
Posted: Sat Mar 22, 2014 11:58 pm
by Simon
Hi ledrac,
I was so disappointing with that lesson I've made a stack for you:
This stack shows you the basics of saving/loading a preference file and binary data to a specific folder on your drive.
Most of the scripts are in the buttons.
It might not be commented enough but I'm lazy.
Be sure to look at the preference.txt file that is save to see how easy it is. No need for 100's of cards just 100's of lines in a single text file.
I left out editing of the text description, something you may want to do. I leave it up to you to figure that part out but gCounter has everything to do with it.
Simon
Edit: I will not say that the methods I use are the "Best" just another way.