Page 1 of 1

Does closeStack trigger in the iOS simulator?

Posted: Wed Sep 07, 2011 12:54 am
by stevenchalmers
The "closeStack" message seems to work fine when closing a stack from within LiveCode but does not seem to trigger for me when running the same stack in the simulator. It also does not work on my iPhone.

See the attached stack and here is the code:

-------------------------------------------------------------------------------------------------------------

on openStack
put "Time stamp: " & the MyTimeStamp of this stack into field "TimeStampField"
end openStack

on closeStack
set the MyTimeStamp of this stack to the milliseconds

save this stack
pass closeStack

end closeStack

-------------------------------------------------------------------------------------------------------------

What I expect is that each time the stack closes it updates the stack custom property "MyTimeStamp". Then, each time the stack is opened it displays the previously saved "MyTimeStamp" in the field "TimeStampField"

What I get is the time stamp that was placed in the custom property while I executed it from within LiveCode and the value never changes.

LiveCode build 1445 4.6.3
xCode 4.1

Steven (Colorado, USA)

Re: Does closeStack trigger in the iOS simulator?

Posted: Wed Sep 07, 2011 9:30 am
by Jellicle
You can't make an app from a stack, make changes to that stack at runtime, and then save that stack - the app bundle can't be modified at run time. You can only save stacks that are being run from one of the allowed folders on the device. So your app will need a launch stack that on first launch writes the main stack to the Documents folder, and then goes to that stack (it goes directly to the stack on subsequent launches). You can save that stack.

Gerry

Re: Does closeStack trigger in the iOS simulator?

Posted: Wed Sep 07, 2011 10:56 am
by Klaus
Hi all,

in this case here it might suffice to "spit out" a little text

Code: Select all

on closestack
   put the millisecs into url("file:" & specialfolderpath("documents)" & /myTimeStamp.txt")
   ###...
end closestack
file and read it in when the app starts the next time:

Code: Select all

on openstack
   if there is a file (specialfolderpath("documents)" & /myTimeStamp.txt") then
      put url("file:" & specialfolderpath("documents)" & /myTimeStamp.txt") into fld "TimeSTampField"
   else  
       ## optional
       put empty into fld "TimeSTampField"
   end if
end openstack
Definitively NO need to save the stack 8)


Best

Klaus

Re: Does closeStack trigger in the iOS simulator?

Posted: Wed Sep 07, 2011 11:00 am
by Jellicle
Yeah I thought of that (and do it my own apps) but it seemed a good opportunity to explain why the mechanism being used was failing :)

gerry

Re: Does closeStack trigger in the iOS simulator?

Posted: Wed Sep 07, 2011 2:25 pm
by stevenchalmers
Gerry, Klaus,

Thanks so much for this information. The pair of responses is perfect. I needed the explanation of why the mechanism was failing and also needed to learn about the special folder path.

Thanks so much.

I'll let you know when the app is in iTunes!


Steven

Re: Does closeStack trigger in the iOS simulator?

Posted: Wed Sep 07, 2011 4:02 pm
by Klaus
Hi Steven,

glad we could be helpful in both respects :D

Ah, and welcome to the forum!


Best from germany

Klaus