A little confusion about save stack
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
forgive me, but this is a bit hard to explain, and thank you for your patience and help. I think the problem is the complexity of my array. It is set up as tMainArray[documentnumber][linknumber][miscData] (documentnumber and link number are literal numbers in the keys miscdata is several word named keys) besides having the numbered keys at each level there are also some named keys that tell me about the contents of the numbered elements and about the parent element. eg tMainArray[1][nooflinks] holds the total number of how many numbered child elements there are in tMainArray[1] and tMainArray[1][docname] holds the name of the document that tMainArray[1] represents. When I save the array and reload it, I can retrieve the data from tMainArray[x][x], but the data in the third level of elements is gone.
e.g if tMainArray[3][2][coords] = 122,12,129,65
and tMainArray[3][nooflinks] = 7
after saving and loading
tMainArray[3][nooflinks] will still be 7 however, tMainArray[3][2][coords] will be empty.
e.g if tMainArray[3][2][coords] = 122,12,129,65
and tMainArray[3][nooflinks] = 7
after saving and loading
tMainArray[3][nooflinks] will still be 7 however, tMainArray[3][2][coords] will be empty.
Hmm Interesting. I just tried the following code:
This worked as expected. Its much simplified of course, but is putting the correct information into the message box, so I have a couple questions for you.
Is coords used elsewhere, so maybe its seeing it as a variable? If thats the case, using quotes as mentioned earlier will help with that issue.
I assume you've built the array, and checked the values before and after setting and recapturing the array from the properties, and you can pop the information out before not after right? Thats why I used 2 diff array names so that I can check whats was put in vs what was returned.
How are you putting the coords into the array? Is it possible they're going in as keys and not values?
You can test this theory to eliminate it by putting
into your code. If it returns 122 12 129 65 that tells you something right there. If not, you can eliminate that as a possibility.
Code: Select all
on mouseUp
put "122,12,129,65" into myA[1][1][coords]
set customProperties["myAProps"] of this stack to myA
put customProperties["myAProps"] of this stack into testA
put testA[1][1][coords]
end mouseUp
Is coords used elsewhere, so maybe its seeing it as a variable? If thats the case, using quotes as mentioned earlier will help with that issue.
I assume you've built the array, and checked the values before and after setting and recapturing the array from the properties, and you can pop the information out before not after right? Thats why I used 2 diff array names so that I can check whats was put in vs what was returned.
How are you putting the coords into the array? Is it possible they're going in as keys and not values?
You can test this theory to eliminate it by putting
Code: Select all
answer the keys of testA[3][2][coords]
magice wrote:forgive me, but this is a bit hard to explain, and thank you for your patience and help. I think the problem is the complexity of my array. It is set up as tMainArray[documentnumber][linknumber][miscData] (documentnumber and link number are literal numbers in the keys miscdata is several word named keys) besides having the numbered keys at each level there are also some named keys that tell me about the contents of the numbered elements and about the parent element. eg tMainArray[1][nooflinks] holds the total number of how many numbered child elements there are in tMainArray[1] and tMainArray[1][docname] holds the name of the document that tMainArray[1] represents. When I save the array and reload it, I can retrieve the data from tMainArray[x][x], but the data in the third level of elements is gone.
e.g if tMainArray[3][2][coords] = 122,12,129,65
and tMainArray[3][nooflinks] = 7
after saving and loading
tMainArray[3][nooflinks] will still be 7 however, tMainArray[3][2][coords] will be empty.
I did a test like yours before I implemented in my app. In my test it seemed to work fine. The array is exactly as it should be, because the app works. It uses the array to generate linked image map html documents. Exporting to html works like a charm so I know the array is properly filled. However after saving and loading it does not. I wonder if it could have something to do with having keys that have no value. There are situations where, if the end user picks a document to edit and then changes his mind there will be a key that has an empty value. Could that be gumming up the works? Maybe the save process doesn't know how to handle these empty keys, and so it puts the next key in the value slot of the last key instead of leaving it empty? That could explain some eratic behavior i have observed.
Hmm, not sure at this point. Since you did a test like mine and it worked it does seem like we're missing something.
If what you're asking is what is actually happening, it makes me wonder if some of the keys ever get created when you restore from the custom property. IE does return coords (from your example) as one of the keys, whether its empty or not?
I have a suspicion that you'll keep beating your head against this wall then have an Ah HAH moment, but things are getting complicated enough now its hard to know how to help without you posting lots of code.
I'll keep thinking on it and try to reproduce the problem locally here. If you find the answer let me know if you would?
Thanks
If what you're asking is what is actually happening, it makes me wonder if some of the keys ever get created when you restore from the custom property. IE does
Code: Select all
answer the keys of tMainArray[3][2]
I have a suspicion that you'll keep beating your head against this wall then have an Ah HAH moment, but things are getting complicated enough now its hard to know how to help without you posting lots of code.

I'll keep thinking on it and try to reproduce the problem locally here. If you find the answer let me know if you would?
Thanks
OK I think I figured it out. The arrays are saving ok. They are not loading.
this is my script for loading:
I can put that in a button and manually load the arrays and every thing works fine. However I was trying to put it in my openCard script so it would run at start up. With a little testing I have determined that this script must be running before the custom properties load. How would be a good way to auto initiate it when the stack loads?
this is my script for loading:
Code: Select all
global tMainArray
global tMainArrayInc
global tSubInc
global tFieldDataArray
global myClick
global tVarSave
put the customProperties["varSave"] of this stack into tVarSave
if tVarSave[5] = true
then
put the customProperties["mainArray"] of this stack into tMainArray
put the customProperties["fieldDataArray"] of this stack into tfieldDataArray
put the customProperties["varSave"] of this stack into tVarSave
put tVarSave[1] into tMainArrayInc
put tVarSave[2] into tSubInc
put tVarSave[3] into tRectInc
put tVarSave[4] into myClick
end if
Problem resolved, and just in case anyone else reads this and is trying to resolve the same issue this is what I did. Since the script worked from a button and not from the openCard command, I created a standard End User License Agreement stack that shows up on openCard. The agree button runs the script.
Thanks for the info. I had another though on how to make it run too if you're interested.
If you put your script for loading into a command say..
and then in openCard put
Does that work?
If you put your script for loading into a command say..
Code: Select all
command loadItUp
Code: Select all
send "loadItUp" to me in 0 seconds
magice wrote:Problem resolved, and just in case anyone else reads this and is trying to resolve the same issue this is what I did. Since the script worked from a button and not from the openCard command, I created a standard End User License Agreement stack that shows up on openCard. The agree button runs the script.