Datagrid for storage

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Redlance305
Posts: 30
Joined: Sun Feb 28, 2010 9:52 pm
Location: Miami, Florida
Contact:

Datagrid for storage

Post by Redlance305 » Sat Nov 20, 2010 9:51 pm

Just checking to make sure I'm not wasting my time.

Have a 'database' in a grid on one card, I step thought it using a loop. (dgnumberoflines and setting the line by using dgHilitedLines)

Works fine in the LiveCode Development language, however when I deploy to an iOS device (iphone/itouch). It doesn't work.

Have I yet again found another unsupported features?

But I'll keep trying, but please let me know if I am spinning my wheels!

Any word on when the finish product will be released?

~David

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

Re: Datagrid for storage

Post by bn » Sat Nov 20, 2010 10:38 pm

David,

I guess (!) that you run into the problem that deploying to iOS is a sort of standalone and you have to include the datagrid template stack

Look at this lesson
http://lessons.runrev.com/spaces/lesson ... Data-Grid-

I did not try to use a datagrid in an app yet. But this is where I would look for a solution.

regards

Bernd

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Location: Fredericktown, MO
Contact:

Re: Datagrid for storage

Post by ctflatt » Sat Nov 20, 2010 10:45 pm

I have loaded the datagrid lesson and tested it in the Simulator. It appears to work with the text, but not images... I may not have included the images directory in the iOS build, but it did populate the text.

Lesson is from here:

http://lessons.runrev.com/spaces/lesson ... -of-People

In the example, the DG is populated from an array...

HTH.

stanier25
Posts: 6
Joined: Sun Nov 14, 2010 4:59 pm

Re: Datagrid for storage

Post by stanier25 » Thu Dec 02, 2010 3:28 pm

I've tried downloading the DG lesson stack and can't get that to work either - whether using the simulator or deployng to a real iPhone. Can't seem to get any action that populates the DG to work although it does display data added to it in Livecode prior to deployment

SteveHanlan
Posts: 80
Joined: Fri Jul 09, 2010 6:28 pm

Re: Datagrid for storage

Post by SteveHanlan » Wed Dec 29, 2010 8:45 am

I'm having the same problem.

I populate the grid from an array matching the Data Grid Template.
It works in the SDK, the Windows App, The Mac App and on the Web, but the dg is not populated on the ipad.
I know I am reading my data file correctly, as a dump the whole thing to a field to verify.
It's like the Data Grid Template is not included in the bundle.

Any help would be appreciated

Steve

SteveHanlan
Posts: 80
Joined: Fri Jul 09, 2010 6:28 pm

Re: Datagrid for storage

Post by SteveHanlan » Wed Jan 05, 2011 7:31 pm

Just got the word from Heather ...

"The Standalone builder doesn't automatically include the datagrid for you on iOS.
You have to manually include it in the build"

I can't try this until this evening, but I thought I tried to do this, but could not find where to locate the template for the datagrid to include it !

If anyone has done this, please let me know

cheers
Steve

Redlance305
Posts: 30
Joined: Sun Feb 28, 2010 9:52 pm
Location: Miami, Florida
Contact:

Re: Datagrid for storage

Post by Redlance305 » Thu Jan 13, 2011 2:26 am

"Just got the word from Heather ...

"The Standalone builder doesn't automatically include the datagrid for you on iOS.
You have to manually include it in the build""

OK I'm clueless, how to I manually include it in the build?

Tried 4.5.3 and still doesn't work without knowing how to include it in the build?

Can anyone help?

Thanks
~David

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Datagrid for storage

Post by Klaus » Thu Jan 13, 2011 1:25 pm

Hi David,

from the 4.5.3 release notes:
- Support for datagrid on iOS (library now correctly included in standalones)

Is that not true?


Best

Klaus

PopMongrel
Posts: 2
Joined: Thu Jan 13, 2011 7:46 pm
Location: Victoria, Canada

Re: Datagrid for storage

Post by PopMongrel » Thu Jan 13, 2011 7:59 pm

Hi All,

I'm new to LC so I'm probably making some fairly obvious mistakes, however, like Steve and others I cannot get the datagrid to work in iOS. I have a simple stack that works in the SDK, but not in iOS. Specifically, the datagrid I've created does not seem to save the data - i.e. it's not persistent between closing and launching of the app. Has anyone been able to get a basic datagrid to work in iOS? If so, could you post a sample stack?

thanks
doug

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Datagrid for storage

Post by Klaus » Thu Jan 13, 2011 8:18 pm

Hi Doug,

the same thing that applies to desktop standalones applies to iOS apps:
Standalones cannot save themselves! PERIOD!

You need to save your data outside of the standalone and import it again the
next time the user starts your app!

Check my recent newsletter articles to get a hint on how to do that:
Part 1: http://runrev.com/newsletter/october/is ... etter3.php
Part 2: http://runrev.com/newsletter/december/i ... etter4.php

Although this was written with desktop apps in mind, it can also be used for iOS apps!
Use specialfolderpath("documents") to save your data on iOS.

And welcome to the forum :)


Best

Klaus

PopMongrel
Posts: 2
Joined: Thu Jan 13, 2011 7:46 pm
Location: Victoria, Canada

Re: Datagrid for storage

Post by PopMongrel » Thu Jan 13, 2011 9:05 pm

Hi Klaus,

Thanks for the reply! I should have done a better job of describing my work - my bad :oops: Here's a more complete description of my situation.

1) I am not trying to save the stack itself (at least not that I'm aware of - I wonder if it should be setting the datagrid property Persistent Data - to False?) . I am writing out a file to the 'Documents' directory using the technique shown in the lesson on writing/reading iOS files. I believe I am handling the iOS directories issue properly. I have gotten the test stack from that lesson to run fine in the Simulator, so I think I'm good on the iOS file location stuff. ( I have read your articles, though not thoroughly. I think I'm basically up to speed on the no saving mainstack and the basics of the workarounds i.e. splash stack method.)

2) I am using dgText, not dgData, to simplify things. At this point the code to save & read is quite simple:

I have these scripts on the card the datagrid is located on:

Code: Select all

on closeCard
   dispatch uiExportData
end closeCard

on openCard
   dispatch uiImportData
end openCard
And I have this as the code for the actual work (located on the stack script):

Code: Select all

command uiExportData
   put the dgText of group "DataGrid 1" into theDataT
   set the defaultFolder to specialFolderPath("Documents") 
   put theDataT into URL("file:medi112s11n01_master.txt")
end uiExportData

command uiImportData
   set the defaultFolder to specialFolderPath("Documents") 
   put  URL("file:medi112s11n01_master.txt") into theDataT
   put false into firstLineContainsHeaders
   set the dgText[firstLineContainsHeaders] of group "DataGrid 1" to theDataT
end uiImportData

3) It works fine as a standalone Mac OS app. However, when I load it in the Simulator, it does not seem to save or read the file. (I'm not actually sure if it is a problem with saving the file on iOS, or reading it - that's what I'm trying to figure out right now.) I think my next step is to insert a simple field (not data grid) and see if I can dump the file I think I'm creating into it.

Any thoughts or hints are greatly appreciated. Also, the articles are well written and useful. Once further along, I will be returning to them to soak up all the knowledge!

thanks
doug

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Datagrid for storage

Post by Klaus » Thu Jan 13, 2011 9:19 pm

Hi Doug,

Ah, I see, but the syntax looks OK!?

You could add an answer after each save/read to check the result and add a "lock screen" before
you set the dgtext and an "unlock screen" after that to force a screen refresh.
...
put theDataT into URL("file:medi112s11n01_master.txt")
answer the result
## Should be empty after successful writing and give a hint if not!
...
...
put URL("file:medi112s11n01_master.txt") into theDataT
answer the result
...
lock screen
set the dgText[firstLineContainsHeaders] of group "DataGrid 1" to theDataT
unlock screen
...


Sorry, no other ideas...


Best

Klaus

Post Reply

Return to “iOS Deployment”