Does closeStack trigger in the iOS simulator?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
stevenchalmers
Posts: 15
Joined: Mon Jul 11, 2011 8:12 pm

Does closeStack trigger in the iOS simulator?

Post by stevenchalmers » Wed Sep 07, 2011 12:54 am

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)

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Does closeStack trigger in the iOS simulator?

Post by Jellicle » Wed Sep 07, 2011 9:30 am

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
14" MacBook Pro
Former LiveCode developer.
Now recovering.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Does closeStack trigger in the iOS simulator?

Post by Klaus » Wed Sep 07, 2011 10:56 am

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

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Does closeStack trigger in the iOS simulator?

Post by Jellicle » Wed Sep 07, 2011 11:00 am

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
14" MacBook Pro
Former LiveCode developer.
Now recovering.

stevenchalmers
Posts: 15
Joined: Mon Jul 11, 2011 8:12 pm

Re: Does closeStack trigger in the iOS simulator?

Post by stevenchalmers » Wed Sep 07, 2011 2:25 pm

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

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Does closeStack trigger in the iOS simulator?

Post by Klaus » Wed Sep 07, 2011 4:02 pm

Hi Steven,

glad we could be helpful in both respects :D

Ah, and welcome to the forum!


Best from germany

Klaus

Post Reply