Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Table Sort Problems


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-20-2007, 03:46 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default Table Sort Problems

I'm trying to create a generic hi-scores table for one of my game apps and also so that I can add it to the code samples for others to use
It's almost finished now but when I add a new score to the table and then sort the scores I find that the rows in the table are being separated instead of being kept together. Here's the section of code that adds the new score to the table and then attempts to sort it...
Code:
Sub UpdateTable(Score,Level)
 ScoresTable.Cell("Score",9)=Score
 ScoresTable.Cell("Level",9)=Level
 ScoresTable.Cell("Date",9)=Date(Now)
 ScoresTable.TableSort ("Score DESC, Level DESC")
 ScoresForm.Show
End Sub
Can you spot what I'm doing wrong please

Thanks,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #2 (permalink)  
Old 05-20-2007, 05:24 PM
Senior Member
 
Join Date: Apr 2007
Location: Kindred,ND
Posts: 101
Default

Just off top of head your quote(") marks have a comma(,) between them.
Reply With Quote
  #3 (permalink)  
Old 05-20-2007, 06:07 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 650
Default

Hmm ... I don't see any error in this code sample.

What happens if you try this:
Code:
Sub UpdateTable(Score,Level)
 ScoresTable.RemoveRow(9)
 ScoresTable.AddRow(Score, Level, Date(now))
 ScoresTable.TableSort ("Score DESC, Level DESC")
 ScoresForm.Show
End Sub
Or what happens, if you change the variable names so that they are different to the column names?

Last edited by specci48 : 05-20-2007 at 06:09 PM.
Reply With Quote
  #4 (permalink)  
Old 05-20-2007, 06:12 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

I've removed the , and then it errors.

I've also tried to sort using only the Score column but it still ends up with the data in the rows getting mixed up. This is probably really simply to solve but its got me beat

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #5 (permalink)  
Old 05-20-2007, 06:57 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

Are the Score and Level columns declared using cNumbers (in the Table.AddCol) ?
Reply With Quote
  #6 (permalink)  
Old 05-20-2007, 08:15 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

No, both columns are set as cStrings because when the table is first started I display blanks but if I set the columns as cNumber then 0's are displayed which looks a little unsightly.
I don't understand why the data in the rows would get mixed up using either cString or cNumber, surely the data in each row should stay constant, just the position of the row should change in relation to the data that is being sorted.

Thanks,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #7 (permalink)  
Old 05-20-2007, 08:32 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

TableSort doesn't sort the table once.
It keeps the table sorted all the time.
Now, when you write:
ScoresTable.Cell("Score",9)=Score
Row 9 will change depending on the score value.
The next update (level update) will update another row.

As specci49 wrote you should add a new row at once and you don't need to use TableSort each time (it doesn't do anything).
Reply With Quote
  #8 (permalink)  
Old 05-20-2007, 09:02 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

When I replied earlier I hadn't seen Specci48's reply, we must have both been replying at the same time. I see now what I need to do, instead of updating the values in the cells I should remove the row and then add a new row with the updated data. I'll give it a go and let you know how I do.

Thanks for the help.

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #9 (permalink)  
Old 05-21-2007, 01:05 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Thank you, removing the last row then adding a new row has done the trick. I hadn't properly understood that TableSort kept the table sorted even after new data is entered.

It's almost ready to be published now

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #10 (permalink)  
Old 05-21-2007, 08:15 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 650
Default

Hi RandomCoder,

it doesn't matter that you missed my post. The same happend to me not long ago. Now I reload every thread I had posted to after sending, just to be sure I hadn't missed something.
And in this special case it was a "plus" to miss it because...
... if you had read my post, you may have changed your code which has solved the problem.
... now Erel has referenced to my post (who the fu.. ist specci49 ??? ) and you changed your code which has solved the problem. But additionally now we all know how TableSort is really working since Erel explained, that a table is sorted all the time.

specci48
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Table.filter problems J12345T Questions & Help Needed 1 08-19-2008 08:19 AM
SORT / TRIM Table(CSV) sintaq Questions & Help Needed 1 03-24-2008 10:52 AM
how to sort this kind of file? Stellaferox Questions & Help Needed 9 02-24-2008 11:21 AM
Table sort / date bob Questions & Help Needed 1 11-16-2007 09:15 AM
Sort with SQL JJM Questions & Help Needed 1 06-07-2007 02:03 PM


All times are GMT. The time now is 02:19 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0