Page 1 of 1

printing and saving from a template

Posted: Tue May 21, 2013 8:55 am
by yarran
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?

Re: printing and saving from a template

Posted: Tue May 21, 2013 9:07 am
by BvG

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

Re: printing and saving from a template

Posted: Fri May 24, 2013 6:47 am
by yarran
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?

Re: printing and saving from a template

Posted: Fri May 24, 2013 7:39 am
by Simon
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

Re: printing and saving from a template

Posted: Fri May 24, 2013 11:25 am
by BvG
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