User Profile and User Properties DB?

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: User Profile and User Properties DB?

Post by bn » Thu Feb 23, 2012 12:31 pm

Hi Barry,

Code: Select all

set the filename of stack "MyData" to gPrefsDat
   
save stack "MyData"
yes you have to save the stack. It will be a stack of the name "myData" although the name of the file on disk will be "Prefs.dat".

I don't know if this is what you want. And you probably don't want to create a stack "myData" every time you start the main stack.

you call initPrefDB on openstack. So every time you open the stack it will create a stack "myData" and save it. You might want to test for the existence of a stack "myData" before you create the stack. If the stack is there I would open the stack.

I always find it safer to enclose literals with quotes. E.g.

Code: Select all

set the text of field txtBarrysFolder to fldrBarrys 
I would say

Code: Select all

set the text of field "txtBarrysFolder" to fldrBarrys
Livecode does the best it can to find out if it is a variable or a literal. But eventually you will mix up the two and get errors that are hard to track down.

Kind regards

Bernd

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: User Profile and User Properties DB?

Post by BarrySumpter » Thu Feb 23, 2012 9:45 pm

bn wrote:Hi Barry,

please have a look at:

http://www.runrev.com/newsletter/januar ... p?a=NWS124

SetPref is a command the way you declared it.

Then:
If I want to change a custom property that is an array I always take the custom property into a local variable, then change the value of the array and set the custom property to the local variable.

instead of:

Code: Select all

on SetPref pLabel, pValue
   put gPrefsDat into tStack
   set the uPrefs[pLabel] of stack tStack to pValue
   save stack tStack
end SetPref
try

Code: Select all

on SetPref pLabel, pValue
   put gPrefsDat into tStack
   put the uPrefs of this stack into tArray -- local variable to hold and change array
   put pValue into tArray[pLabel]
   set the uPrefs of this stack to tArray -- update the custom property with the new values
   save stack tStack
end SetPref
if you want to call this command you would code:

Code: Select all

setPref "userName", lUserName
Kind regards

Bernd
Another missed post.

Sincerely Bernd. Thanks for your continued support.

I thought we had changed the command handler
on SetPref ...
to a function
Function SetPref ...

And now we're dicussing changing it back.

I think when you were writing about command you mean a command handler.

We've discussed at length that prefixes txt means text box and chk means checkbox and btn means button.
We've also established the field "data" saves only milli-seconds of execution times.
And actually takes longer to type the two ".

fresh look this mroning.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: User Profile and User Properties DB?

Post by bn » Thu Feb 23, 2012 10:01 pm

Hi Barry,

good morning.
Over here in Europe I will soon go to bed.
I thought we had changed the command handler
on SetPref ...
to a function
Function SetPref
actually we were talking about GetPrefs.
SetPrefs is a good example for a command (you don't want to get anything back, just set the values) whereas GetPrefs is a good case for a function (you want to get something back). Anyhow you can use either as long as the syntax is right.

have you looked at my latest post regarding saving the "myData" stack?

My remarks about quoting literals was less about execution speed, it happened to me that inadvertently I had used a variable name earlier on and later used the same name for a literal e.g. a field. Thats when things get tricky. But nevermind the quotes, you just have to be aware of a potential problem.

Kind regards

Bernd

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: User Profile and User Properties DB?

Post by BarrySumpter » Thu Feb 23, 2012 10:11 pm

Thanks again for clarifying the differneces between command handlers and function routines.

Would the script we use to call these be referred to as command calls and function calls.
As in Call SetPref and Call GetPref?
Or would some other term be more clear?

Maybe, now some coffe n breakie and I should be right to go.

I find that I have more trouble with syntax errors when I use the "s cause I always forget one.
LOL

Sweet dreams confident in the fact that you have done at least one good deed for the day.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: dataStack - hide stack errors

Post by BarrySumpter » Fri Feb 24, 2012 9:32 pm

Code: Select all

on initPrefDB
   
   set itemDel to slash  -- start to build current path for stackData preferences
   put the effective filename of this stack into realpath  --gets current path
   delete last item of realpath --removes .livecode file name on this stack
   put  realpath & "/Prefs.dat" into gPrefsDat -- adds SQLite file name to path
   
   put "Preferences" into stkPreferneces
   
   if not (there is a file gPrefsDat) then   -- check to see if the preferences stack exists
      create stack stkPreferneces -- doesn't exist - only now create the stack in memory
      set the filename of stack stkPreferneces to gPrefsDat  -- set the filename to folder and path
      save stack gPrefsDat  -- now save/ create the Preferences stack to disk
      hide stack gPrefsDat
   else
      go stack gPrefsDat
      hide stack gPrefsDat    --   =======>>>  errors with "can't find stack"
      --save  stack tFilePath
      --hide stack tFilePath
      --go this stack
   end if
   
end initPrefDB


All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: User Profile and User Properties DB?

Post by bn » Fri Feb 24, 2012 9:50 pm

Hi Barry,

I guess you are pointing to the commentary in your script.

The error probably results from the fact that the name of the stack is "Preferences" as you put into your local variable stkPreferneces

Try:

Code: Select all

hide stack stkPreferneces
or you could probably say

Code: Select all

go invisible stack gPrefsDat
and skip the hide stack part.

Kind regards

Bernd

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: User Profile and User Properties DB?

Post by BarrySumpter » Fri Feb 24, 2012 10:26 pm

Nice!

Go invisible ....
the dictionary even has the
go inivisible stack preferences
as a sample script.

Never would have figured that.

I think I should rename that gPrefsDat to gFldrLocPrefDat for a better description as well.
i.e. not a stk... stack object.

Many Thanks!
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Post Reply