Deleting table field rows

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
LAZ
Posts: 6
Joined: Mon Jan 21, 2008 4:45 pm
Location: England

Deleting table field rows

Post by LAZ » Wed Oct 15, 2008 2:29 pm

Hi guys'n'gals

I have a field of numbers (barcodes) that I loop through in order to populate a table-field with data from a database (i.e. read the barcode and add a row to the table field-showing the product description etc). I populate column one of each table row with an 'X'. If I click in the first column of a row, my code checks for the 'X', then deletes the line from the table and re-populates the table with the remaining rows (by looping the table-field rows to find the 'X's in the first column, building a temporary variable, then writing this back into the table-field). So as far as the user is concerned, the row has now been deleted.

HOWEVER, if I now add a new barcode into the barcode field and process it, the new table-field row this produces does not appear immediately after the 'new' last row but after what appears to be a 'blank' row .... as if the table-field KNOWS that there used to be a row there (like there is a behind-the-scenes row count?)!

I've read everything I can find on table fields and cRevTable but have failed to find a 'row count' setting or anything else that will solve my dilemma ...... please help me!!

Kind regards
Lawrence

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Wed Oct 15, 2008 3:57 pm

Well there's a glib answer and a "well I don't really know without some more info" answer.

To delete a line is there any reason why you aren't simply using

Code: Select all

delete line <x> of field "tableField"
?

And inserting the new line by using

Code: Select all

put cr & <new barcode data> after field "tableField"
?

I'm assuming that your code needs to be more complicated than that, but without some more info as to what you're doing and the how/why of it, I don't know what to suggest.

LAZ
Posts: 6
Joined: Mon Jan 21, 2008 4:45 pm
Location: England

Post by LAZ » Wed Oct 15, 2008 4:14 pm

Thanks for that SparkOut ...... what is it they say about not seeing the wood for the trees??!?

I was indeed doing exactly as you suggested but had got so wrapped up in looking for issues with the 'delete a table row' aspect that I was totally forgetting a global 'line count' variable I was using on the insert side of things. It was this that was holding the original number of rows and causing the odd blank line in the table.

Many thanks for bringing me back to my senses by calmly stating the obvious.

Kind regards
Lawrence

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Wed Oct 15, 2008 4:18 pm

Ah well, that's a happy one then. Good luck with it.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”