Page 2 of 2

Re: Saving Contents of Entire Stack (Window)

Posted: Fri Feb 18, 2011 5:32 pm
by pmc
how do you set a path to a folder? i use this but there's an error:

on openCard
go stack "MyAppData"
end openCard

on createDataStack
clone stack "try me 1"
set the name of stack "Copy of try me 1" to "MyAppData"
set the fileName of stack "MyAppData"to C:/tmp/
save stack "MyAppData"
end createDataStack

It does not clone the stack.

Re: Saving Contents of Entire Stack (Window)

Posted: Fri Feb 18, 2011 6:08 pm
by townsend
Again-- thanks-- I appreciate the help.

Just in case another newbie wonders across this tread, at some later day, I was wrong.
The sub-stack data CAN be saved.

There is a great tutorial on this, by Klaus. I can't post the links, as I'm too new here,
but if you search for the thread named, "saving substack" you'll find it there.

PS: Oh yes-- the Dictionary!
I was wondering where all the Events were. in LC they're called Messages.

Re: Saving Contents of Entire Stack (Window)

Posted: Fri Feb 18, 2011 7:15 pm
by BvG
altho you can't use the save command on substacks of your standalone, you can easily use it on other stacks that are not substacks.

Re: Saving Contents of Entire Stack (Window)

Posted: Fri Feb 18, 2011 7:31 pm
by FourthWorld
Does the clone never appear, or does it merely fail to save where expected?

If the latter, it may be the incomplete path:

set the fileName of stack "MyAppData"to C:/tmp/

Re: Saving Contents of Entire Stack (Window)

Posted: Sat Feb 19, 2011 9:25 pm
by dunbarx
In order to save in a standalone, the working stack must be in its own stack file. Even substacks of a mainStack will not save. But the remedy is simple. You make a mainStack and one or more working substacks. In the standalone application settings, make sure that all substacks are placed into their own "individual stack files". This is a checkbox on the right side of the pane. Now these stacks will still be part of the standalone stack (which cannot be saved) but can themselves be saved.

In the case of a dataGrid, you have to make sure that the "revDatGridLibrary" stack is included. You may have to add this by hand in the stacks pane.

Try it. Make a stack and a substack.ut something on the substack that needs to be saved, like entering data into a field.

In an opencard handler in the mainstack card script, go to the subStack (so it opens at startup).
Makse sure that you have a closeStack handler in the mainstack that saves upon quitting.

In the standalone application settings, you will see the substack in the "stacks" pane. Make sure that the 'move stacks to individual stackfiles" is checked.

Make the standalone. put data into the field. Quit. The data is there when you reopen.

Call back if you need to. The problem is simple to solve, but several things have to be in place.

Craig Newman

Re: Saving Contents of Entire Stack (Window)

Posted: Sat Feb 19, 2011 10:55 pm
by Zryip TheSlug
The better trick to have the LC app builder adding the revdatagridlibrary stack is to follow this lesson:

http://lessons.runrev.com/spaces/lesson ... Data-Grid-

This lesson explains how to add a fake "data grid templates" sub stack in a splash screen to force the builder adding the datagrid library.


Best regards,

Re: Saving Contents of Entire Stack (Window)

Posted: Tue Feb 22, 2011 3:54 am
by Danny
I'm coming into this topic with a hopefully simple request. How do I save text fields only on iOS. Not in a Mac app just iOS.

These Level 1-1, and so on, are changing numbers 1 through 3 and I want to save this in between user sessions.

Code: Select all

on preOpenStack
   put fld "Level 1-1" + fld "Level 1-2" + fld "Level 1-3" into fld "minApples"
   set the defaultFolder to specialFolderPath("preferences")
   put fld "Level 1-1" into URL ("file:iphonetest.txt")
   put fld "Level 1-2"  into URL ("file:iphonetest2.txt")
   put fld "Level 1-3" into URL ("file:iphonetest3.txt")
   open stack "Main Menu"
end preOpenStack

on closeCard
      save stack "Main Menu" as "/Macintosh HD/documents"
   set the defaultFolder to specialFolderPath("preferences")
   open file "file:iphonetest.txt" 
   open file "file:iphonetest2.txt" 
   open file "file:iphonetest3.txt"
end closeCard
and that didn't work. I've looked at many tutorials and just haven't been able to strike the right answer. :(

So if you could help that'd be amazing. I know that some things just aren't easy but I feel like there has to be a simpler way to save some little text fields.
Sample code would be the best but an explanation of how to do save text fields on iOS would be just as good. I would like to say that I have seen the tutorial in RunRev's lesson section. I'm sorry if the answer is in this post but I either didn't understand it or I missed it. I've been trying to finish my app for a while and I keep finding things that I need to do.

Thanks,

Danny

Re: Saving Contents of Entire Stack (Window)

Posted: Tue Feb 22, 2011 1:08 pm
by Klaus
Hi Danny,

I also highly recommend to go through these stacks to get more of the basics of LiveCode:
http://www.runrev.com/developers/lesson ... nferences/

Of course you want tot write the info to disk then the stack CLOSES
and read in again when the stack starts -> PROPENSTACK! 8)
Please read my comments!

Code: Select all

on preOpenStack
   ## Read prefs if already present:

   ## Does not work in standalone, so leave it out!
   ## save stack "Main Menu" as "/Macintosh HD/documents"

   ## Try to avoid to "set the defaultfolder...", instead concatenate the neccessary pathnames!
   ## Read three files, if PRESENT!
   if there is a file (specialfolderpath("documents") & "/iphonetest.txt")) then
        put url("file:" & (specialfolderpath("documents") & "/iphonetest.txt")) into fld XYZ
   end if
    
   ## Same for other files
  ## ..
end preOpenStack

on closeCard
   ## Save info to disk
   put fld "Level 1-1" & fld "Level 1-2" & fld "Level 1-3" into fld "minApples"
   put fld "Level 1-1" into URL ("file:" & (specialfolderpath("documents") & "/iphonetest.txt"))
   put fld "Level 1-2" into URL ("file:" & (specialfolderpath("documents") & "/iphonetest2.txt"))
   put fld "Level 1-3" into URL ("file:" & (specialfolderpath("documents") & "/iphonetest3.txt"))
end closeCard
Best

Klaus

Re: Saving Contents of Entire Stack (Window)

Posted: Tue Feb 22, 2011 3:04 pm
by pmc
I like to thank Klaus for helping me out on saving to a standalone.

I tried the 'save as individual file' method and it finally works. Thank you guys for being so patience and keeping cool. Now I want the 'splash' stack to disappear after, say 2 seconds.

On opencard
go stack "tryMe3"
set the visible of me to 2 seconds
end opencard

I got errors. How should I go about it?

Re: Saving Contents of Entire Stack (Window)

Posted: Tue Feb 22, 2011 4:39 pm
by Klaus
Hi Choong,

"visible" is a property that can only be TRUE or FALSE!
After you went to stack "tryMe3" the "defaultstack" IS "tryMe3"so you need to:

Code: Select all

On opencard
  go stack "tryMe3"
  wait 3 seconds with messages
  set the visible of stack "Mainstack or Splash stackname here" to FALSE
end opencard
I tried the 'save as individual file' method and it finally works.
Again, don't forget, this will only work for users with ADMIN rights, since only ADMINS
may write (save stacks) in the Application folder!!!

Best

Klaus

Re: Saving Contents of Entire Stack (Window)

Posted: Tue Feb 22, 2011 5:19 pm
by pmc
Hi Klaus

Thanks...this means other users can't really use the app....someone that share the computer without the admin's right.....is this correct? Unless you specify another folder for the sub stacks, right?

Re: Saving Contents of Entire Stack (Window)

Posted: Tue Feb 22, 2011 5:51 pm
by Klaus
Hi Choong,
pmc wrote:Hi Klaus

Thanks...this means other users can't really use the app....someone that share the computer without the admin's right.....is this correct?
This is correct!
pmc wrote:Unless you specify another folder for the sub stacks, right?
Yes, but you need to do this manually (via script in standalone!) somehow, since the
standalone builder can only copy stacks into the distribution folder!

Best

Klaus

Re: Saving Contents of Entire Stack (Window)

Posted: Tue Feb 22, 2011 8:47 pm
by Danny
Hey Klaus,

I actually have been going through that link slowly but surely. :D

This is some great code but it won't save. I simply copied and pasted this into the card script and ran it on my iPod and simulator to no avail. Also i've noticed that the preOpenCard only runs once so if you open the card then close it, then open it again then it won't go through the script that you have laid out for it. Same with closeStack. I have Exit on Suspend off and file sharing on in the standalone settings and I have it saving it as individual stack files. Am I doing something wrong? Let me know what I can do.

If you need more script let me know and I will post.

Thanks,

Danny