databases on iPhone

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3998
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: databases on iPhone

Post by bn » Fri Jan 14, 2011 9:18 pm

Hi sylvan,
All I really want for Christmas, is for someone to upload a launcher stack with a database stack that allows you to add records/cards to the database stack and allows you to modify fields and change the state of buttons and have it all be saved when you close the stack and the new record/stacks and data modifications still there when you reopen the stack in the iPhone simulator. Santa, are you listening???
Apparently Santa lives in Edinburgh and might have heard you. :) Just a small delay in delivery, but you know the snow and all that...

But then again if Sylvan were your first name wouldn't it mean 'the one from the woods'? Than you should know him better than I do and could talk him into a lot of things...

Hope this does what you want.

Kind regards

Bernd

bdtrauma
Posts: 34
Joined: Fri Dec 24, 2010 11:37 pm

Re: databases on iPhone

Post by bdtrauma » Sat Jan 15, 2011 9:09 am

it works in simulator... just can't get it to work on ipad. I turn my ipad off and back on to see if the db stack saved and no data exists. I have to be doing something wrong because I want this to work so badly!

Bert

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3998
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: databases on iPhone

Post by bn » Sat Jan 15, 2011 12:21 pm

Hi Bert,

I tried it on the iPhone and it works if you press the save button first in the present version. I was not happy with the save button as apparently the only means to save.

I did tried to catch a lot of messages in the database stack and the standalone stack to save the database 'automatically' yesterday. Of course I left out the one that works: :)

In the stack script of the database stack:

Code: Select all

on shutDown
   save this stack
end shutDown
that works for me on the iPhone and the iPad.

Now the data in the database stack is saved no matter how you exit the program: by hitting the home button or going to the standalone stack and quit from there. Or if a phone call arrives. No more need to hit the save button.

If you try this, please make shure you delete any prior version of the app you installed on either iPhone or iPad (press the app symbol until all symbols start to jiggle, then you have the delete symbol at all symbols, press that for your app and confirm the dialog box that appears). It happened twice to me that Xcode asked to replace but did not properly load the new version. That can be very confusing.

So now this should be a feasible way to use stacks as a database on the iOS.

Kind regards

Bernd

bdtrauma
Posts: 34
Joined: Fri Dec 24, 2010 11:37 pm

Re: databases on iPhone

Post by bdtrauma » Sat Jan 15, 2011 8:22 pm

Yes! Got it to work... did some weird stuff on the ipad screen, but it did save. I included the database stack in the mobile plugin file. Thanks Bernd and everyone working to get this to work. Now it's time to tinker in my app and get it to work there. :lol:

Bert

sylvanr
Posts: 80
Joined: Wed Nov 24, 2010 10:38 am

Re: databases on iPhone

Post by sylvanr » Mon Jan 17, 2011 3:53 am

Bernd,
I guess I'm missing something? Your stacks work perfectly fine when I download them and put them into the simulator but when I start fooling around, making my own modifications, it quits working. I examined your standalone stack and when I looked at the custom properties of that stack in the stack inspector, I don't see that the database stack was saved as a custom property? Hm. I'm a little confused? Earlier in the discussion, in your original stacks you had uploaded, the database was saved as a custom property of the standalone with the savecustomproperty button? I will keep playing with it and see if I can stumble across a solution.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3998
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: databases on iPhone

Post by bn » Mon Jan 17, 2011 10:34 am

Sylvan,

It changed with the latest upload. I dont use a custom property anymore but include the database stack at build time.
you set up the stack Standalone with the standalone application settings for iOS, nothing special there. Then you go in the -> standalone application settings to -> copy files, there you include the "database.livecode" stack.
But remember in the simulator or on a real device: if you load a new version delete the old one from the simulator or device. The "database.livecode" stack, that is copied into your app winds up in the documents folder, which apparently is not overwritten when you update you app.

Kind regards

Bernd

sylvanr
Posts: 80
Joined: Wed Nov 24, 2010 10:38 am

Re: databases on iPhone

Post by sylvanr » Mon Jan 17, 2011 7:57 pm

I am starting to stumble across some success but still having questions. Will continue to "play" for a while and then will post my questions. Thanks Bernd!

sylvanr
Posts: 80
Joined: Wed Nov 24, 2010 10:38 am

Re: databases on iPhone

Post by sylvanr » Mon Jan 17, 2011 10:48 pm

1st two questions:

#1: In my past experience with other database programs, when you press the "tab" key, it takes you to the next field. This doesn't seem to happen in the iOS?

#2: My radio buttons look like regular radio buttons before importing into the iOS but then the graphic of the button changes so that it is no longer a round circle. The button either points up or points down rather than having the circle fill with black as it does outside the iOS?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3998
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: databases on iPhone

Post by bn » Tue Jan 18, 2011 12:39 am

Hi Sylvan,

on an iPhone/iPad there is no keyboard, that is always available. These are touch devices. So you could do a swipe-gesture to go to the next card or previous card.
If you add this to the script of the stack data

Code: Select all

## the push right or left is here
## note the script local variable sX on top of the script

local sX
on mouseDown
   put the mouseH into sX
end mouseDown


on mouseUp
   put the mouseH - sX into tDistance
   if abs (tDistance) > 10 then
      lock screen
      if tDistance > 0 then 
         go prev card
         unlock screen with visual effect push right
         select empty
      else
         go next card
         unlock screen with visual effect push left
         select empty
      end if
   end if
end mouseUp
## end push right or left
you will have a means to 'swipe' through the cards.
The button either points up or points down rather than having the circle fill with black as it does outside the iOS?
many of the livecode elements on the iPhone do not look like they look in Livecode. From the iOS release notes:
rendering of controls with non-system themes (default is Motif theme)
For the iPhone/iPad you would have to do many elements with images. You take a button and set its icon to an image. Actually you would want to have two images, one hilited and one unhilited. So this is more work than in livecode itself.

regards
Bernd

sylvanr
Posts: 80
Joined: Wed Nov 24, 2010 10:38 am

Re: databases on iPhone

Post by sylvanr » Fri Jan 21, 2011 8:43 pm

Bernd,
Thanks for your responses and I keep moving forward but I do have another question. I have been studying your stacks and when you open the database stack, it automatically puts the date and time that the stack was opened into one of the fields but I don't see any programming for this? There is nothing in the button that opens the database stack that says to put the date and time into a field. There is nothing in the script for the database stack itself that says to put the date and time into a field. I have been trying to figure out where that comes from?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3998
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: databases on iPhone

Post by bn » Sun Jan 23, 2011 8:48 pm

Hi Sylvan,
when you open the database stack, it automatically puts the date and time that the stack was opened into one of the fields but I don't see any programming for this?
it is in the card script of the database stack.

Code: Select all

on opencard
   put "opened" && the long time into field 2
   --select text of field 2
   select empty
end opencard
Kind regards

Bernd

sylvanr
Posts: 80
Joined: Wed Nov 24, 2010 10:38 am

Re: databases on iPhone

Post by sylvanr » Wed Jan 26, 2011 8:30 pm

So I made great progress in the last couple of weeks since the release of 4.5.3 which fixed that bug and got a simple database working in iPhone simulator. I never could get it to save using this code in the database stack, though:

on shutDown
save this stack
end shutDown

I can get it to save using a button with:

on mouseUp
save this stack
end mouseUp

I created an icon and a splash screen image and that all worked fine. I joined the Apple developer program and got the provisioning certificate. I was able to create a standalone application and got it onto my iPhone for troubleshooting. I have used the standalone to database method (sometimes called elsewhere the launcher method or splash screen method). In the simulator, the standalone stack opens and you click on the "go to database" button and it all works. Once I saved as a standalone app, and put it on the iPhone, with my provisioning certificate, and I click the "go to database" button, nothing happens? Am I missing something?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3998
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: databases on iPhone

Post by bn » Wed Jan 26, 2011 8:50 pm

Hi Sylvan,

where is the

Code: Select all

on shutDown
save this stack
end shutDown
command?
In the card script or the stack script of the database stack?

if it is in the card script you might be on another card when the shutDown message comes.

For me it works in the stack script of the database stack.

Did you transfer the database stack to the documents folder first?

It also works on my iPhone/iPad.

Maybe you would want to post a zipped version of your splashscreen stack and the database stack.

Kind regards

Bernd

sylvanr
Posts: 80
Joined: Wed Nov 24, 2010 10:38 am

Re: databases on iPhone

Post by sylvanr » Sat Jan 29, 2011 8:38 pm

Going back to my comment: "Once I saved as a standalone app, and put it on the iPhone, with my provisioning certificate, and I click the "go to database" button, nothing happens?" I just want to report that when I went back and studied your stacks, Bernd, and compared the button script for going to the database, I was able to find my error. I have now got my "app" onto my iPhone and the launcher stack button opens the database stack! It has taken me a while to get there but with your help and the help of others here on the forum, I have actually got a working app! It does save the data using the button with the "on mouseup" script but have still not gotten it to save using the "on shutdown" script. Today, I went back again to your standalone/database stacks and replaced the original stack script which hadn't worked with the "On shutdown" script you had suggested and saved it as an app and put it on my iPhone. I opened it and went to the database stack, made some changes and then exited and upon re-entry, it had saved the changes as you had said it would. Hm. I'm not sure why the exact, same script doesn't work in my stack? I will keep working on it.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3998
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: databases on iPhone

Post by bn » Sat Jan 29, 2011 8:57 pm

Hi Sylvan,

If you put this on a iPhone be very careful to always delete the app completely from the iPhone before uploading the new version.

The reason is that if you update the app only the app will be updated not the documents folder. So even if you change your datastack in Livecode and want to update the one on the iPhone it will not replace the one that is already in the documents folder. When your splash app starts it will look in the documents folder, if there is a stack of the name of your database stack then it will not replace it with the new version.

WHENEVER YOU CHANGE YOUR APP DELETE THE VERSION YOU PUT ON THE SIMULATOR OR THE IPHONE FIRST BEFORE TESTING THE NEW VERSION.

If you put

Code: Select all

on shutDown
save this stack
end shutDown
into the stack script of the database stack it should work.

Please tell me if you tried it this way.

Kind regards

Bernd

Post Reply

Return to “iOS Deployment”