button makes form open

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
ledrac
Posts: 4
Joined: Fri Mar 21, 2014 10:42 am

button makes form open

Post by ledrac » Fri Mar 21, 2014 10:47 am

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?

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: button makes form open

Post by dave.kilroy » Fri Mar 21, 2014 10:51 am

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
"...this is not the code you are looking for..."

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

Re: button makes form open

Post by Klaus » Fri Mar 21, 2014 1:06 pm

Hi ledrac,

you might want to take a look at these stacks, great learning resources:
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

ledrac
Posts: 4
Joined: Fri Mar 21, 2014 10:42 am

Re: button makes form open

Post by ledrac » Sat Mar 22, 2014 8:10 am

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.

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

Re: button makes form open

Post by Simon » Sat Mar 22, 2014 8:19 am

Hi ledrac,
Take a look at "template" in the dictionary.
Specifically templateCard

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

ledrac
Posts: 4
Joined: Fri Mar 21, 2014 10:42 am

Re: button makes form open

Post by ledrac » Sat Mar 22, 2014 9:16 am

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?

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

Re: button makes form open

Post by Simon » Sat Mar 22, 2014 10:00 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

ledrac
Posts: 4
Joined: Fri Mar 21, 2014 10:42 am

Re: button makes form open

Post by ledrac » Sat Mar 22, 2014 10:47 am

Thanks, it does make sense. I will study

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

Re: button makes form open

Post by Simon » Sat Mar 22, 2014 11:58 pm

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. :wink:

Simon
Edit: I will not say that the methods I use are the "Best" just another way.
Attachments
myPlants.zip
LC 6.5 updated April 9 2014
(2.21 KiB) Downloaded 166 times
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply