saving variables in a custom property

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
reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

saving variables in a custom property

Post by reelstuff » Wed May 14, 2008 2:33 pm

I have an application that I am working on setting up some registration fields.

I was looking for a way to save the registration information entered by the user so that the next time they open the program they will not have to enter the same information again.

I looked in the docs and thought that I could set a custom property, however, the custom property does not remain once the application is closed.
Tip:
To save a variable's value, set a custom property of the stack to the value of the
variable in your applications closeStackRequest or shutDown handler. To
restore the variable, put the custom property into a variable in the application's startUp or openStack handler.
Anyone have any idea what the docs are referring to in the above statement.

I can see that a custom property of the stack must be set, but not sure how that would work in the closeStackRequest.

I have my variables set up in two fields,

Code: Select all

myRNfield

myEMfield
--the custom property is setup using a variable
set the myProp1 of fld "myRNfield" to RNdata1
set the myProp2 of fld "myEMfield" to EMdata2

The fields contents are setup as a custom property,

how can I save these vars to a custom property using the close stack request?

Or is there an easier way to save field variables.

From the reading I have done, there only appears to be two ways to save a fields contents, either using a custom property, or
setting up a separate stack as described in the docs.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Wed May 14, 2008 5:32 pm

You still have to save thge stck using the 'save' command. Note that this will only work if that stack is not an embedded part of your standalmone application. Also see: http://www.revjournal.com/tutorials/sav ... ution.html for an excellent overview of your options for saving data.

Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

Post by reelstuff » Wed May 14, 2008 6:47 pm

Janschenkel wrote:You still have to save thge stck using the 'save' command. Note that this will only work if that stack is not an embedded part of your standalmone application. Also see: http://www.revjournal.com/tutorials/sav ... ution.html for an excellent overview of your options for saving data.

Hope this helped,

Jan Schenkel.
Thanks Jan, I will study that carefully, I did not realize this was the case, at first because you can save the stacks in the IDE, but not in the standalone.

So now back to the chalk board,

Tim

reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

Post by reelstuff » Thu May 15, 2008 3:41 pm

I read through the tutorial, very good, I was able to

create a function to handle some data,

Code: Select all

on saveRegFileGen
  put the filename of this stack into tPath
set the itemDelimiter to "/"
put "regFileGen/" into last item of tPath
if there is not a folder tPath then create folder tPath
put fld Field_regData1 into URL ("file:" & tPath & "RegData")
put tPath into fld testing
end saveRegFileGen
This works nicely, it creates the folder path, and then the file RegData in the folder path of the stack,

Now that I have a nice method of storing data, I am now looking at accessing that data, cross platform, for MAC and Win

I tried a number of attempts at getting the file data that is stored, however I failed to
correctly access the data, perhaps due to getting the right file path and then accessing that folder and file data,

I tried reconstructing the path, I know that the data is there in that path.

So, I tried,

Code: Select all

on mouseUp
 put the filename of this stack into tPath
set the itemDelimiter to "/"
put "regFileGen/" into last item of tPath
put (tPath & RegData) into myregVar
--just a test to see if I am getting the correct path
put myregVar into fld testing2
--this gives me the URL to the file, now I just need to figure out how to get the contents of the file and put it into
--a field where I can manage the data. 


--get line 1 of fld regData1 put it into fld "myRNfield"
--get line 2 of fld regData1 put it into fld "myEMfield"
end mouseUp
I looked over the docs but could not find exactly what I was after, or missed it entirely.

thanks for any suggestions

Tim

Tim
Posts: 29
Joined: Wed Oct 31, 2007 12:56 pm

Post by Tim » Thu May 15, 2008 3:57 pm

you should be able to use:

put URL ("file:" & myregVar) into field "Field_regData1"

reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

Post by reelstuff » Thu May 15, 2008 4:12 pm

Tim wrote:you should be able to use:

put URL ("file:" & myregVar) into field "Field_regData1"

Perfect, thank you, I am still amazed at how simple it can be to do things in REV, I think I am just stuck in the it must be hard mode.

Post Reply