Datagrid - dgNumberOfLines not working in iOS

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 - dgNumberOfLines not working in iOS

Post by Redlance305 » Sat Dec 04, 2010 6:07 pm

put the dgNumberOfLines of group "DataGrid" on Card "Card02" into theLineNo

Have tried every which way from Sunday to get Datagrid to work, with no luck.

We're using datagrid as a storage location for a 'database' or list of our site locations. 375 of them. Which our program steps though to find a matching site. IE: 0621, will display the site info for site 0621. Simple right. Works fine in Mac OS as an Application and in the LiveCode Development language, but not on the iOS device. It does not return the "dgNumberOfLines" which is requested before looping through the datagrid one item at a time.

What would appear to be a simple task just doesn't work. Am I missing something. Mind you I've added a LOT of code just to fine my error, (debug) but I don't think it is a programming error.

So most of this code shouldn't be needed.

Card 1 contains the input fields for the search, right now we are just working with one MailCode.

Card 2 contains the datagrid of 375ish data lines.

Card 3 displays the search results. Again this works fine in Mac OS, but nothing is ever displayed in iOS.

Logic error? Coding Error? Or LiveCode Error?
Anyone with ideas on why this doesn't work? Again I know a lot of the code really isn't needed I'm debugging here!

~David
-------------------------------------

set the dgFocus of group "DataGrid" on Card "Card02" to true
set the dgHilitedLines of group "DataGrid" on Card "Card02" to "1"
select of group "DataGrid" on Card "Card02"
put the dgNumberOfLines of group "DataGrid" on Card "Card02" into Field "MyNumberOfRecords" on Card "Card01"
put the dgNumberOfLines of group "DataGrid" on Card "Card02" into theLineNo

put Field "InputMailCode" on Card "Card01" into MailCodeSearch
put MailCodeSearch into field "MySearchFor" on Card "Card01"
show (1) cards
ClearDisplayOnCard03

if the length of MailCodeSearch = 4 then
repeat with LineCount = 1 to theLineNo
put LineCount into field "MyRecordCount" on Card "Card01"
set the dgHilitedLines of group "DataGrid" on Card "Card02" to LineCount
put the dgHilitedLines of group "DataGrid" on Card "Card02" into theLine
put the dgDataOfLine[theLine] of group "DataGrid" on Card "Card02" into theDataA

if MailCodeSearch = theDataA["MailCode"] then
put theDataA["Group"] into Field "Group" on Card "Card03"
put theDataA["MailCode"] into Field "MailCode" on Card "Card03"
put theDataA["FacilityName"] into Field "FacilityName" on Card "Card03"
put theDataA["FacilityAddress"] into Field "FacilityAddress" on Card "Card03"
put theDataA["City"] into Field "City" on Card "Card03"
put theDataA["State"] into Field "State" on Card "Card03"
put theDataA["Zip"] into Field "Zip" on Card "Card03"
put theDataA["Phone"] into Field "Phone" on Card "Card03"
put theDataA["FAX"] into Field "FAX" on Card "Card03"
put theDataA["MDCPSRegion"] into Field "MDCPSRegion" on Card "Card03"
put theDataA["ITSRegion"] into Field "ITSRegion" on Card "Card03"
put theDataA["VotingDistrict"] into Field "VotingDistrict" on Card "Card03"
put theDataA["SupportTeam"] into Field "SupportTeam" on Card "Card03"
go to Card "Card03"
exit repeat
end if
end repeat
end if
end mouseUp

On ClearDisplayOnCard03
put "Searching" into Field "Group" on Card "Card03"
put empty into Field "MailCode" on Card "Card03"
put empty into Field "FacilityName" on Card "Card03"
put empty into Field "FacilityAddress" on Card "Card03"
put empty into Field "City" on Card "Card03"
put empty into Field "State" on Card "Card03"
put empty into Field "Zip" on Card "Card03"
put empty into Field "Phone" on Card "Card03"
put empty into Field "FAX" on Card "Card03"
put empty into Field "MDCPSRegion" on Card "Card03"
put empty into Field "ITSRegion" on Card "Card03"
put empty into Field "VotingDistrict" on Card "Card03"
put empty into Field "SupportTeam" on Card "Card03"
end ClearDisplayOnCard03
---------------

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

Re: Datagrid - dgNumberOfLines not working in iOS

Post by Redlance305 » Sat Dec 04, 2010 6:13 pm

OH another thing:

dgNumberOfLines never returns a number, even before the search starts. I poll dgNumberOfLines to return the number of lines in the datagrid before doing anything and it is empty (in iOS). So in my opinion, there is a problem with dgNumberOfLines under iOS!

~David

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

Re: Datagrid - dgNumberOfLines not working in iOS

Post by Klaus » Sat Dec 04, 2010 6:41 pm

Hi Lance,

a shot in the dark, but can't you check:
the num of lines of the dgText of grp "DataGrid"
?
Supposed your grid is in table mode!


Best

Klaus

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

Re: Datagrid - dgNumberOfLines not working in iOS

Post by Redlance305 » Sat Dec 04, 2010 7:33 pm

Thanks for the quick reply.

Yes, grid is in Table mode.

Added:
put the num of lines of the dgText of grp "DataGrid" on Card "Card02" into theLineNo
put the num of lines of the dgText of grp "DataGrid" on Card "Card02" into Field "MyNumberOfRecords" on Card "Card01"

Same results, worked fine in development mode and as an Mac OS program. But not as an iOS app.

Didn't return a 'record' count (number of rows from the datagrid that contains our 'database')..

Again thanks for something else to try, pulling what hair I have left OUT.. <grin>

Did not see the "num of lines" in the documentation (as part of datagrid).

~David

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

Re: Datagrid - dgNumberOfLines not working in iOS

Post by Klaus » Sat Dec 04, 2010 7:41 pm

Hi David,
Redlance305 wrote:Did not see the "num of lines" in the documentation (as part of datagrid).
simply because this is not a special DataGrid command! :D

"num" = abbreviation for "number"
Lazy moi 8)

There is a LOT that is not working on iDevices (yet)!


Best

Klaus

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

Re: Datagrid - dgNumberOfLines not working in iOS

Post by Redlance305 » Mon Dec 06, 2010 1:25 am

Did so more playing today.... See code below.

As near as I can tell DataGrids are not working at all under iOS.
If so please let me know so I can stop wasting time trying to get it to work!

Basically I am assuming I display the datagrid then step through it searching for the matching mail code. Again it works fine under the OS X version, but not the iOS version.

Another option would be a database, however I've yet to see if that is being supported under iOS. Any examples on using the database feature yet? Any clue when the next iOS Version is going to be released?

~David



on mouseUp
ClearDisplayOnCard03
go to Card "Card02"
set the dgFocus of group "DataGrid" on Card "Card02" to true
set the dgHilitedLines of group "DataGrid" on Card "Card02" to "1"
select of group "DataGrid" on Card "Card02"

put Field "MyNumberOfRecords" on Card "Card01" into theLineNo
put Field "InputMailCode" on Card "Card01" into MailCodeSearch
put MailCodeSearch into field "MySearchFor" on Card "Card01"
#show (1) cards
go to Card "Card03"
put "0" into field "MailCode" on Card "Card03"
put 0 into LineCount
put 0 into MailCodeFlag

if the length of MailCodeSearch = 4 then
go to Card "Card02"
set the dgFocus of group "DataGrid" on Card "Card02" to true
select of group "DataGrid" on Card "Card02"
repeat with LineCount = 1 to theLineNo
#put LineCount into field "MailCode" on Card "Card03"
set the dgHilitedLines of group "DataGrid" on Card "Card02" to LineCount
#put the dgHilitedLines of group "DataGrid" on Card "Card02" into theLine
#put the dgDataOfLine[theLine] of group "DataGrid" on Card "Card02" into theDataA
put the dgDataOfLine[LineCount] of group "DataGrid" on Card "Card02" into theDataA
put theDataA["MailCode"] into MailCodeTest

if MailCodeSearch = MailCodeTest then
put theDataA["Group"] into Field "Group" on Card "Card03"
put theDataA["MailCode"] into Field "MailCode" on Card "Card03"
put theDataA["FacilityName"] into Field "FacilityName" on Card "Card03"
put theDataA["FacilityAddress"] into Field "FacilityAddress" on Card "Card03"
put theDataA["City"] into Field "City" on Card "Card03"
put theDataA["State"] into Field "State" on Card "Card03"
put theDataA["Zip"] into Field "Zip" on Card "Card03"
put theDataA["Phone"] into Field "Phone" on Card "Card03"
put theDataA["FAX"] into Field "FAX" on Card "Card03"
put theDataA["MDCPSRegion"] into Field "MDCPSRegion" on Card "Card03"
put theDataA["ITSRegion"] into Field "ITSRegion" on Card "Card03"
put theDataA["VotingDistrict"] into Field "VotingDistrict" on Card "Card03"
put theDataA["SupportTeam"] into Field "SupportTeam" on Card "Card03"
go to Card "Card03"
put 1 into MailCodeFlag
exit repeat
end if
end repeat
end if
if MailCodeFlag = 0 then
go to Card "Card01"
end if
end mouseUp

On ClearDisplayOnCard03
put "Searching" into Field "Group" on Card "Card03"
put empty into Field "MailCode" on Card "Card03"
put empty into Field "FacilityName" on Card "Card03"
put empty into Field "FacilityAddress" on Card "Card03"
put empty into Field "City" on Card "Card03"
put empty into Field "State" on Card "Card03"
put empty into Field "Zip" on Card "Card03"
put empty into Field "Phone" on Card "Card03"
put empty into Field "FAX" on Card "Card03"
put empty into Field "MDCPSRegion" on Card "Card03"
put empty into Field "ITSRegion" on Card "Card03"
put empty into Field "VotingDistrict" on Card "Card03"
put empty into Field "SupportTeam" on Card "Card03"
end ClearDisplayOnCard03

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

Re: Datagrid - dgNumberOfLines not working in iOS

Post by Klaus » Mon Dec 06, 2010 12:30 pm

Hi David,

1. ## Any examples on using the database feature yet?
Externals, and database access is implemented via externals in LC, are not yet supported,
but definitvely will in one of the next versions of the mobile plug in.

2. ## Any clue when the next iOS Version is going to be released?
No :)

3. Could you please use the "Code" button above to format your scripts after pasting them here?
It is very hard to read right now.

4. The official syntax is: "control x OF card y"
So even if this is working right now, the engine might get "stricter" and less forgiving in future versions, as I have experienced in the past! 8)


Best

Klaus

Zryip TheSlug
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 163
Joined: Tue Jan 26, 2010 10:15 pm
Contact:

Re: Datagrid - dgNumberOfLines not working in iOS

Post by Zryip TheSlug » Tue Dec 07, 2010 11:16 am

Redlance305 wrote:put the dgNumberOfLines of group "DataGrid" on Card "Card02" into theLineNo
Hi David,

Trying to interact with a datagrid in a hidden card will working only:
- if you go on the card which contain the datagrid. You need to do this only one time offscreen, before to interact with the datagrid
- if you populate it with its own content:

Code: Select all

set the dgText of grp "MyGrid" to the dgText of grp "MyGrid"
or

Code: Select all

set the dgData of grp "MyGrid" to the dgData of grp "MyGrid"

Why?
Because the datagrid is initialized on the preOpenControl message or since a recent version of the library, when you repopulate it with its content.
If the datagrid is not properly initialized, the indexes not exist in the datagrid and so the dgNumberOfLines will not work.

This is true with a regular stack. Never tested in iOS.

Try to go on card "Card02" before the execution of the line:

Code: Select all

put the dgNumberOfLines of group "DataGrid" on Card "Card02" into theLineNo
And see if it fixes the issue.
Redlance305 wrote: set the dgFocus of group "DataGrid" on Card "Card02" to true
set the dgHilitedLines of group "DataGrid" on Card "Card02" to "1"
select of group "DataGrid" on Card "Card02"
put the dgNumberOfLines of group "DataGrid" on Card "Card02" into Field "MyNumberOfRecords" on Card "Card01"
put the dgNumberOfLines of group "DataGrid" on Card "Card02" into theLineNo

put Field "InputMailCode" on Card "Card01" into MailCodeSearch
put MailCodeSearch into field "MySearchFor" on Card "Card01"
show (1) cards
ClearDisplayOnCard03

if the length of MailCodeSearch = 4 then
repeat with LineCount = 1 to theLineNo
put LineCount into field "MyRecordCount" on Card "Card01"
set the dgHilitedLines of group "DataGrid" on Card "Card02" to LineCount
put the dgHilitedLines of group "DataGrid" on Card "Card02" into theLine
put the dgDataOfLine[theLine] of group "DataGrid" on Card "Card02" into theDataA

if MailCodeSearch = theDataA["MailCode"] then
put theDataA["Group"] into Field "Group" on Card "Card03"
put theDataA["MailCode"] into Field "MailCode" on Card "Card03"
put theDataA["FacilityName"] into Field "FacilityName" on Card "Card03"
put theDataA["FacilityAddress"] into Field "FacilityAddress" on Card "Card03"
put theDataA["City"] into Field "City" on Card "Card03"
put theDataA["State"] into Field "State" on Card "Card03"
put theDataA["Zip"] into Field "Zip" on Card "Card03"
put theDataA["Phone"] into Field "Phone" on Card "Card03"
put theDataA["FAX"] into Field "FAX" on Card "Card03"
put theDataA["MDCPSRegion"] into Field "MDCPSRegion" on Card "Card03"
put theDataA["ITSRegion"] into Field "ITSRegion" on Card "Card03"
put theDataA["VotingDistrict"] into Field "VotingDistrict" on Card "Card03"
put theDataA["SupportTeam"] into Field "SupportTeam" on Card "Card03"
go to Card "Card03"
exit repeat
end if
end repeat
end if
end mouseUp
---------------
You can find a value in a datagrid by using the FindLine or the FindIndex command. Have a look to the datagrid API.


Regards,
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel

Post Reply

Return to “iOS Deployment”