Creating a template Card?

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
Not a lot of thought
Posts: 77
Joined: Thu May 21, 2015 2:41 am

Creating a template Card?

Post by Not a lot of thought » Thu May 21, 2015 2:51 am

I'm a little new to this forum thing, forgive me if I am misusing it. My question is relatively simple. I have a decently complex card with a lot of code that I don't want to have to embed into another object's code script. I would really just like to make that card a template card in the background of the program where it wouldn't be navigable and of which I could make clones or copies via a button on another card. Is there a way to make that card unnavigable?

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

Re: Creating a template Card?

Post by dunbarx » Thu May 21, 2015 3:52 am

Hi.

Simple to make it unnavigable, depending on how you navigate. How do you?

If the card is never intended to be navigated to, does that mean there are no controls on that card? I ask because if so, you do not need that card at all, and can move all your handlers to the stack script or beyond.

And if the card is not intended to ever show, why do you need to clone it? Is it special just because of the code resident in its script? But if that is true, then how do you intend to access that code from the rest of your stack? You can explicitly send messages to that card script, but that is clunky, if intended as an integral part of the whole. Do you know what the "templateCard" is?

What I mean is this: the nature of your question implies, at least to me, that a reorganization of the stack itself might be more prudent. Anyway, write back with any and all of your thoughts or rebuttals.

Craig Newman

Not a lot of thought
Posts: 77
Joined: Thu May 21, 2015 2:41 am

Re: Creating a template Card?

Post by Not a lot of thought » Thu May 21, 2015 11:34 am

No, I'm not familiar with the TemplateCard.

To answer your question regarding why even have the card. The card or at least a copy thereof, is and will be an integral part of the program's navigational and databasing system. Essentially, it might be thought of as a subfolder beneath the first card in that path's navigational structure.
Say, for instance you want to create a program that provides the user with the capacity to store his/her own information about a given subject like a book, but you want to provide the flexibility for them to record the information they want about any book not just a general list. So instead of making a list for the user, which may not contain all of the items they wish to report on, you allow them to create their own list. So at the first level of the data they would be asked to what type of book (fiction, non-fiction). That card is easy enough, but at the next level down in the data they would need to know what kind of book (mystery, inspirational, educational, etc) and you want the user to have the capacity to create his own list of subcategories. So now on the second card it needs to be labeled and contain all of the same objects as the first, but with the next level down's categories (user-made).
So on the first card you would need to create a second card that is added to the navigational scheme of the stack that is labeled and filled out by the first card's entry field. That card is blank, except for all of the standard objects on that card (add button, delete button, entry field, etc.), but the script of those standard objects all contain sophisticated code that I'm not interested in embedding into the first card's subcategory input field add button.
So instead of creating a whole new card for that subcategory then embedding all the objects, code, etc into that card through the add button's script, I have created a template card which currently just sits in last position in the stack. The template card (just a regular card with all of the objects and script) would then just be copied and added to the navigational scheme of the program via the first card's "add" button. I'd rather that card not even be part of that stack, but it obviously has to be part of the program or at least part of the accessible files downloaded with the program.
So,
Card 1 (fiction or non-fiction)
Card 2 (user defined subcategory) template copied and added into navigational scheme
Card 3 (user defined sub-subcategory) template copied and added into navigational scheme

Does that make sense?

Not a lot of thought
Posts: 77
Joined: Thu May 21, 2015 2:41 am

Re: Creating a template Card?

Post by Not a lot of thought » Thu May 21, 2015 11:36 am

Navigational scheme has two options:
Via the stack's home page
Via a back button for backward navigation

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Creating a template Card?

Post by SparkOut » Thu May 21, 2015 1:18 pm

How are you navigating through the cards? If you never have an instruction to go to the template card, then nobody will see it. If you are using the arrow keys on the keyboard, this can be turned off in the preferences and/or setting the navigationArrows property to false.
You could also go to the extreme of making a substack holding the template card and copy from there to the mainstack.

Randy Hengst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Thu Jun 29, 2006 4:16 pm

Re: Creating a template Card?

Post by Randy Hengst » Thu May 21, 2015 3:16 pm

I’ve used an “art card” that I’ve copied from one stack to another… when both stacks are open I have this code in a button in the template stack:

copy card “ArtCard" of stack “myTemplate" to stack “TargetStackName"

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Creating a template Card?

Post by MaxV » Thu May 21, 2015 4:27 pm

You could try:

Code: Select all

clone card "mytemplate"
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Not a lot of thought
Posts: 77
Joined: Thu May 21, 2015 2:41 am

Re: Creating a template Card?

Post by Not a lot of thought » Sat May 23, 2015 12:13 pm

Thanks SparkOut. I did go the extra mile and create a substack. Randy when you copy the card from one stack to another do both stacks have to be open? If so, do both have to be visible to the user? Next I'm still struggling with how to copy or clone something then rename it to something unique in order that I can manipulate the copy or clone separately from another. I especially struggle with renaming copied groups. Any pointers?

Randy Hengst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Thu Jun 29, 2006 4:16 pm

Re: Creating a template Card?

Post by Randy Hengst » Sat May 23, 2015 1:39 pm

My "copy card" example is part of my work in the IDE... yes, I have both stacks open. So,this is not part of any "standalone" distribution. I bet a substack method for what I do would be just fine.

randy

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Creating a template Card?

Post by MaxV » Sun May 24, 2015 3:22 pm

Here an example:

Code: Select all

clone card "mytemplate" #now we have 2 identical card, with the same name
set the short name of card "mytemplate" to "mynewcard" # now one card changed name
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”