printing and saving from a template

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
yarran
Posts: 5
Joined: Thu May 31, 2012 9:28 pm

printing and saving from a template

Post by yarran » Tue May 21, 2013 8:55 am

I am writing a program which has templates. These templates use pull down menus as well as text entry boxes to make choices and write text respectively. The choices from the pull down menus and the text form a record which I want to save as a separate file (or card?) which could later be amended. There are no actions taken from the pull down menu - only the menu choice is kept as a record and saved. The user should be able to do this many times and save on each occasion as separate entities while leaving the template untouched. How can I implement this?

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: printing and saving from a template

Post by BvG » Tue May 21, 2013 9:07 am

Code: Select all

answer file ""
put the label of button "my drop down" into url ("file:" & it)
also check out these dictionary entries:
menuhistory property
label property
menuPick message

answer file (with type) command
defaultfolder property
url keyword
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

yarran
Posts: 5
Joined: Thu May 31, 2012 9:28 pm

Re: printing and saving from a template

Post by yarran » Fri May 24, 2013 6:47 am

Thanks BvG.
But I want to save and print the card because the card is a template. The card has about 20 pulldown menus arranged in a structure which I want to preserve, so i really don't want to save each menu option as a part of a text file. As far as I can see it is only possible to save a stack.
There are other cards which also are templates and I want to treat them the same.

Can I set each template(cookie mold) up as a substack? but how do I then save the cookies made from the mold?

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

Re: printing and saving from a template

Post by Simon » Fri May 24, 2013 7:39 am

Hi yarran,
What Björnke has suggested is the way to go. Standalones can not be saved, you will have to save the label of each menu externally.

It's not really that hard to do plus it's useful to know how in many situations.
What will happen is:

Code: Select all

on openCard
put url("file:myCardOne.txt") into tVar
repeat for each line tLine of tVar
add 1 to n
 set the label of button "ComboBox Menu" & n to tLine
end repeat
That assumes each menu item is saved on a single line of myCardOne.txt and your menus are named ComboBox Menu1, ComboBox Menu2 etc.
On closeCard you would do the opposite to save all the currently selected values back to myCardOne.txt

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

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: printing and saving from a template

Post by BvG » Fri May 24, 2013 11:25 am

Actually, if you want to save a card as a whole, it's possible to copy it to another (fresh) stack, and then save that stack. Look at the dictionary for these helpful entries:

copy command (especially the third example)
create stack command
clone command
save command
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Post Reply