Page 1 of 2

cannot see custom properties after close/reopen

Posted: Wed Jun 06, 2018 11:39 pm
by markhinnebusch
I am trying to build an automated upgrade feature based on the splash screen method and I have it almost working (I think).

I have a stack (appState) with custom properties that include the version number of other stacks. When I startup,the splash stack saves all of the custom properties of the appState stack and then closes and clears the stack. the splash stack then renames the appState stack's file from appState.livecode by appending "old" to it, yielding appState.livecode.old. (for recovery if there is a problem). I then connect to the server and get a new version of the appState stack and I write that to a file with the original stack name, appState.livecode. I then open that stack. I want to compare the custom properties with those that I saved from the old version of the stack but the custom properties of the new stack are all empty. That is, if i put "answer the appName of stack appState into the message box, it displays nothing.

Except that they are there. If I use the stack inspector, I can see all of the properties and their values.

So, I'm stumped. Is there something that I need to do to let my script see the custom properties? I tried putting a 2 second delay in, but that did nothing. I closed and reopened the new stack. No change. If I close and reopen Live Code, then the properties can be seen by my script but I really don't want to make the user close and restart the app.

Any help will be greatly appreciated.

thanks,
mark

Re: cannot see custom properties after close/reopen

Posted: Thu Jun 07, 2018 11:12 am
by Klaus
Hi Mark,

not sure what's going on...

You wrote:
...get a new version of the appState stack and I write that to a file with the original stack name, appState.livecode. I then open that stack. I want to compare the custom properties with those that I saved from the old version of the stack but the custom properties of the new stack are all empty.
Unless the CPs have been in that new stack from the server, I'd exspect this stacks CPs to be "empty".

However, since you only renamed the FILENAME of the stack, maybe the inspector still displays the OLD stacks content with FILLED custom properties?

LC still has problems with two or more stacks with the same name, although they have different IDs.


Best

Klaus

Re: cannot see custom properties after close/reopen

Posted: Thu Jun 07, 2018 3:37 pm
by markhinnebusch
Klaus,

Thanks for the quick response.

The stack from the server does have the CPs filled in and when i close LC and restart it, everything works fine. So, I'm guessing the problem is having the two stacks with the same name even though I close and clear the one before I open the other. I can try renaming the stack as well as the file and see if that helps. I'm also going to try to put the data into fields instead of CPs and see if that works. Can you think of anything else that I could do?

thanks,
mark

Re: cannot see custom properties after close/reopen

Posted: Thu Jun 07, 2018 4:01 pm
by Klaus
Hi Mark,

if the "destroystack" and "destroywindow" of the stack is set to TREU, then this should not happen.
Maybe also issue:

Code: Select all

...
delete stack "name of troublemaker here"
## To completely remove that stack from memory
...
before loading the new stack.
Sorry, no other brilliant idea...

Best

Klaus

Re: cannot see custom properties after close/reopen

Posted: Thu Jun 07, 2018 4:16 pm
by bogs
Klaus wrote:
Thu Jun 07, 2018 4:01 pm
if the "destroystack" and "destroywindow" of the stack is set to TREU, then this should not happen.
Guess this answers the question of whether or not it is difficult to spell short words, like 'Klaus', which is far more difficult than 'TRUE' :twisted:
<ducking>

Re: cannot see custom properties after close/reopen

Posted: Thu Jun 07, 2018 4:17 pm
by Klaus
Ouch, touché!

At least TREU is german for "faithful" :-D

Re: cannot see custom properties after close/reopen

Posted: Thu Jun 07, 2018 4:37 pm
by bogs
:mrgreen: :mrgreen:

Re: cannot see custom properties after close/reopen

Posted: Thu Jun 07, 2018 6:37 pm
by markhinnebusch
OK, I tried renaming the old stack and no dice. So then I tried using fields instead of CPs and that works.

So, the upshot is that when replacing a stack dynamically from a server, do not depend on CPs; use fields instead. At least for now. For me, this is no problem because the stack is never visible in the application since it serves only to contain application parameters. In fact, this made me realize that I can use the stack on the server to manage those parameters with a nice GUI. So it was a win-win.

thanks for the help,
Mark

Re: cannot see custom properties after close/reopen

Posted: Fri Jun 08, 2018 2:02 am
by jameshale
Isn’t a custom property set (i.e. properties, not a single property) an array?
Using “Answer” to display an array doesn’t show anything does it?
What if you ask to see the “keys” of your custom property (set)?

Re: cannot see custom properties after close/reopen

Posted: Fri Jun 08, 2018 10:31 am
by Klaus
Hi James,

Mark did not mention CP Sets at all, and "answer the whatever of this stack" DOES work for him, not just in the right moment.


Best

Klaus

Re: cannot see custom properties after close/reopen

Posted: Fri Jun 08, 2018 10:36 am
by jameshale
Hi Klaus,
He mentioned properties plural so i thought he may have them bundled as a set.
My reading of his post was that using ‘answer’ from the message box gave him nothing, which implied to me it did not work.

Re: cannot see custom properties after close/reopen

Posted: Fri Jun 08, 2018 4:46 pm
by FourthWorld
Without seeing the code for the sequence any answer will be guesswork.

Re: cannot see custom properties after close/reopen

Posted: Fri Jun 08, 2018 4:55 pm
by markhinnebusch
I was looking at individual custom properties, not sets.

Re: cannot see custom properties after close/reopen

Posted: Fri Jun 08, 2018 4:58 pm
by FourthWorld
Does appState have to be a stack? If you're just using a stack as a container for properties an array may be simpler, completely bypassing any possibility of complications from stack name conflicts.

Re: cannot see custom properties after close/reopen

Posted: Fri Jun 08, 2018 5:09 pm
by jacque
I have a huge project that fetches stacks remotely and each stack has hundreds of custom properties. I've never had a problem with them, so I suspect something else is going on, possibly in the handler that does the stack swap and renaming. It might help for us to see that script segment.