Page 1 of 1
preferences stack
Posted: Sat May 10, 2014 12:43 pm
by keram
Hi,
I created a separate stack in the specialFolderPath to save and to retrieve preferences of standalone apps.
When I start the main app the pref stack gets opened automatically and is visible in the Project Browser.
Is that how it should be?
keram
Re: preferences stack
Posted: Sat May 10, 2014 2:03 pm
by Klaus
Hi keram,
keram wrote:I created a separate stack in the specialFolderPath...
WHAT specialfolderpath?
keram wrote:When I start the main app the pref stack gets opened automatically and is visible in the Project Browser.
Automatically? And you did not script to open that stack?
Can't believe it
keram wrote:Is that how it should be?
What "should" be in your opinion?
General hint: You do not need to actuially OPEN or GO to a stack if you want to store something in its custom properties!
This will do:
...
put specialfolderpath("desktop") & "/a stack.rev" into tPrefsFile
set the cAnyStoredValue of stack tPrefsFile to the hilite of btn 1
save stack tPrefsFile
close stack tPrefsFile
...
This way the stack will be "opened" invisibly and without any messages, so you can manipulate it,
but need to SAVE and CLOSE after you are done.
Best
Klaus
Re: preferences stack
Posted: Sat May 10, 2014 6:22 pm
by keram
Hi Klaus,
Klaus wrote:WHAT specialfolderpath?
Sorry for not being more specific right from the start.
with this code:
Code: Select all
switch platform()
case "android"
## Android
put specialFolderPath("documents") into gSFPath
break
case "Win32"
## Everything >= Win2000
if the systemversion contains "NT" then put specialFolderPath(26) into gSFPath
break
case "MacOS"
## MacOS X
put specialFolderPath("preferences") into gSFPath
break
end switch
put gSFPath &"/MQdata" into gSFPath
if there is not a folder gSFPath then new folder gSFPath --new folder
if result() <> empty then answer "Sorry, but there was a problem writing to a .rev file." with "OK"
-----
if there is no file (gSFPath &"/prefs.rev") then
createDataStack
-----
on createDataStack
clone invisible stack "prefs" --- this is a substack with default preferences
set the name of stack "Copy of prefs" to "preferences"
set the fileName of stack "preferences" to gSFPath &"/prefs.rev"
put gSFPath &"/prefs.rev" into gPrefsFile
save stack gPrefsFile
close stack gPrefsFile
end createDataStack
on closeStack
save stack gPrefsFile
close stack gPrefsFile
end closeStack
I wasn't using this line
put gSFPath &"/prefs.rev" into gPrefsFile before; was using
("file:" & gSFPath &"/prefs.rev") which wasn't really right and created another problem; now saving and retrieving the data works OK.
Klaus wrote:Automatically? And you did not script to open that stack?
Can't believe it

Yes, when I open the main stack i see this:

- prefs stack1.png (8.55 KiB) Viewed 3857 times
and then once I make some changes to the settings and they get saved I see this:

- prefs stack2.png (7.62 KiB) Viewed 3857 times
No I don't script to open that prefs stack; also when I open couple of cards then that prefs stack pops up again in the Project Browser.
Klaus wrote:What "should" be in your opinion?
I think that prefs stack should not pop up automatically in Project Browser. Doesn't it mean that it's open? It should not open by itself.
I'll keep searching through the code and try to find why it opens automatically.
keram
Re: preferences stack
Posted: Sat May 10, 2014 6:46 pm
by Klaus
Hi Keram,
yes, I see, and no, it should not open automatically!
Maybe somewhere in your scripts you refer to that stack and it opens?
Best
Klaus
Re: preferences stack
Posted: Sat May 10, 2014 7:18 pm
by keram
Klaus wrote:Maybe somewhere in your scripts you refer to that stack and it opens?
On couple of places this line was there:
set the cMySelection of stack gPrefsFile to gMySelection
so I added:
save stack gPrefsFile
close stack gPrefsFile
Klaus wrote:This way the stack will be "opened" invisibly and without any messages, so you can manipulate it,
Now it opens only when when the main stack opens, but it's not visible, I only see it in the Project Browser.
Could it be that it does so because the preferences are loaded from the prefs stack?
keram
Re: preferences stack
Posted: Sat May 10, 2014 7:23 pm
by Klaus
Hi Keram,
not sure, and definitively no idea what the project browser is doing anyway
Best
Klaus
Re: preferences stack
Posted: Sat May 10, 2014 7:39 pm
by keram
Hi Klaus,
I figured it out.
When the main stack opens then 2 preferences are read from the prefs stack:
put the cMySelection of stack gPrefsFile into gMySelection
put the cMyCategories of stack gPrefsFile into gMyCategories
this makes the prefs stack appear in Project Browser.
Then I added
close stack gPrefsFile after the above 2 lines and all is OK, I hope.
Thanks for your help
keram