Saving Variables and Settings (or even a Stack)

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
MasterchiefJB
Posts: 76
Joined: Sat Nov 07, 2009 7:43 pm

Saving Variables and Settings (or even a Stack)

Post by MasterchiefJB » Sat Nov 07, 2009 9:42 pm

Hello,

I did a quick search but I didn't find the information I need.

I have a stack which asks the User for a Directory. The Filepath is stored in a local variable. How can I save or store this variable (because if I close the stack and reopen it in standalone mode the variable has changed into the default value).

I tried the save this stack command but that doesn't solve the problem.

Code for the "Browse for Directory" Button

Code: Select all

on mouseUp
  global tRRWADDirectory
  answer folder "Please choose the folder with your default WAD files. Rock Raiders Maindirectory"
  put it into tRRWADDirectory
  if there is no folder tRRWADDirectory then exit mouseUp
  
  put tRRWADDirectory into field "Folder"
  write tRRWADDirectory to file "Directory.dat"
  

  
  
end mouseUp
As you can see I tried to store the value in a file which should be loaded on every start of the application but that doesn't work too.

Thanks for help,
Masterchief J.B

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Post by sturgis » Sat Nov 07, 2009 10:34 pm

In a standalone, savestack doesn't work for the mainstack. Theres a thread here somewhere that goes into explaining how to use a splashstack to open another stack, and on close it then saves the 2nd stack. Mainstacks can't be saved if i understand correctly.

As for keeping the information in a file, that should work, but without more code to see whats up, hard to say whats wrong.

Ah HA found the link I was thinkin of.

Check out this thread. http://forums.runrev.com/phpBB2/viewtop ... highlight=

MasterchiefJB
Posts: 76
Joined: Sat Nov 07, 2009 7:43 pm

Post by MasterchiefJB » Sun Nov 08, 2009 10:59 am

Thank you very much! I found the solution and now my App behaves like it should.

A strange thing I discovered is Win7 and Vista. My app should create a backup of some files and later load this backup back.

Button: Create Backup

Code: Select all

on mouseUp
   create folder "Backup"
   revCopyFile "LegoRR0.WAD","Backup"
   revCopyFile "LegoRR1.WAD","Backup"
end mouseUp
Button: Restore Backup

Code: Select all

on mouseUp
    revCopyFile  "Backup/LegoRR1.WAD","LegoRR1.WAD"
    revCopyFile  "Backup/LegoRR0.WAD","LegoRR0.WAD"
end mouseUp
This works great under Windows XP Me and 2000 but under Vista and Win7 it does nothing.

Any Idea why this happens?

Thank you very much,
MasterchiefJB

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Post by sturgis » Sun Nov 08, 2009 3:11 pm

Hmm, I have no access to windows at all at the moment, so can only shoot in the dark here.

Is an error generated?

If no error, can you try absolute paths rather than relative and see if it works?

If an error IS generated, whats the error?

MasterchiefJB wrote:Thank you very much! I found the solution and now my App behaves like it should.

A strange thing I discovered is Win7 and Vista. My app should create a backup of some files and later load this backup back.

Button: Create Backup

Code: Select all

on mouseUp
   create folder "Backup"
   revCopyFile "LegoRR0.WAD","Backup"
   revCopyFile "LegoRR1.WAD","Backup"
end mouseUp
Button: Restore Backup

Code: Select all

on mouseUp
    revCopyFile  "Backup/LegoRR1.WAD","LegoRR1.WAD"
    revCopyFile  "Backup/LegoRR0.WAD","LegoRR0.WAD"
end mouseUp
This works great under Windows XP Me and 2000 but under Vista and Win7 it does nothing.

Any Idea why this happens?

Thank you very much,
MasterchiefJB

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Sun Nov 08, 2009 4:49 pm

I think what bites ou here is virtualisation under Win Vista or higher. You might want to store your files in a place known to have write permissions and restore it from there if necessary.

One place I can think of would be specialfolderpath(35)

Hth,

Malte

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Sun Nov 08, 2009 4:53 pm

This link will be handy:

http://www.sonsothunder.com/devres/revo ... ile010.htm

Hth,

Malte

MasterchiefJB
Posts: 76
Joined: Sat Nov 07, 2009 7:43 pm

Post by MasterchiefJB » Tue Nov 10, 2009 10:22 pm

Thank you very much! Now it's also working with Win7! The Core works now I will have to implent my download system.

This Program will allow the user to download mods from a server. I want all the uploaded mods to be listened in a field. The User selects a listened mod and clicks on the button "Download" and voila everything is downloaded and installed.

I just have to work out how this could be done^^.
With Revolution it isn't that difficult as with C++;)

Post Reply