Saving data to a datastack

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
Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

Saving data to a datastack

Post by Glenn Boyce » Mon Jun 28, 2010 2:14 am

I have now got my application working fine when it's in development mode. I have a completely separate stack that opens with the Main stack that I am using as a database stack. When I close the main stack the contents of two fields on separate cards are meant to be saved into two fields on separate cards in the data stack. On opening the main stack it all works the other way around. Everything works fine in development mode but when I set up a stand alone application the save script doesn't work but strangely enough the the upload script does. I have attached the code which is saved to Card one of the main stack - someones recommendation to stop it working when I opened substacks.

Code: Select all

on openstack
  lock screen
  
  
  put filename of this stack into f
  set itemdel to "/"
  put "aperiodata.rev" into last item of f
  open stack f
  hide stack f -- keeps the stack open but hidden
  
  
  put fld "ProductSpecs" of card "productSpecs" of stack "Aperiodata" into fld "productSpecs" of card "Product Specification" of stack "FFF - Aperio Version3"
  put fld "blends" of card "blends" of stack "Aperiodata" into fld "specdata" of card "Compound Specification" of stack "FFF - Aperio Version3"
  unlock screen
end openstack

on closestack
  put fld "productSpecs" of card "Product Specification" into fld "ProductSpecs" of card "productSpecs" of stack "Aperiodata"
  put fld "specdata" of card "Compound Specification" into fld "blends" of card "blends" of stack "Aperiodata"
  save stack "Aperiodata"
  close stack "Aperiodata"
end closestack
Any assistance greatfully accepted.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Saving data to a datastack

Post by Klaus » Mon Jun 28, 2010 11:47 am

Hi Glenn,

are you sure that the user (standalone) has WRITE permission in the app folder (or where your standalone resides)?

You could check this:
...
save stack "Aperiodata"
if the result <> empty then
## COuld not save for whatever reason
answer the result
end if
...

Best

Klaus

Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

Re: Saving data to a datastack

Post by Glenn Boyce » Sat Jul 03, 2010 2:13 am

Hi Klaus

No I'm not sure. I'll try you script. how do you set up write permission? it works fine prior to me saving the main stack as a astand alone.

cheers

Glenn

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Saving data to a datastack

Post by Klaus » Sat Jul 03, 2010 10:58 am

Hi Glen,

you will not be able to set any permissions on the target users machine from within your app!
And I thank god for this :-)

Therefore you need to save your files/stacks to a place where you definitvely
HAVE write permission (and where prefs should go in general!) and that is
Mac:
specialfolderpath("preferences")

Windows:
specialfolderpath(26)
## For the current user only
OR
specialfolderpath(35)
## For ALL user of that Win machine

And it is also good style to create a subfolder there for your app prefs.


Best

Klaus

Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

Re: Saving data to a datastack

Post by Glenn Boyce » Sun Jul 04, 2010 11:51 pm

Thanks Klaus. I don't actually understand what you mean. What would the syntax be? I have the application and the data file in the same folder on our S: drive which is a publically accessible drive.
Kind regards, Glenn

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Saving data to a datastack

Post by Klaus » Mon Jul 05, 2010 10:28 am

Hi Glenn,

hmm, typical example of bad communication! :D

I was presuming that your app was in the "regular" application (Programm files on Win) folder
since you did not tell exactly where your app resides.

Only a user with admin rights can write to this namely folder.
That's why I gave you some hint about folders where EVERY user may write to.
Check "specialfolderpath()" in the docs (Rev dictionary).

Did you try this one:
...
save stack "Aperiodata"
if the result <> empty then
## Could not save for whatever reason
answer the result
end if
...
?
If yes, what did you get?

Without any further info we can only guess!


Best

Klaus

Post Reply