Finding data in a table

diego

Member
Licensed User
Longtime User
Hi, this is my first post, as I recently started using Basic4ppc.

I'm trying to get a value in a table with two columns (i.e. "A", "B") but I don't know the row number, I need something like:

table1.AddRow(15, 5)
table1.AddRow(32, 7)

x=table1.cell("A", <row no. that matches with the value '7' in "B" column>)
(result should be 32)

any ideas?

thanks and sorry for my awful english.
 

diego

Member
Licensed User
Longtime User
thanks Klaus, I was thinking in something like this.

¿do you think there could be a delay if I put this Do..Loop code in a timer_tick (100 ms) event? (my table should not have more than 500 rows).
 

diego

Member
Licensed User
Longtime User
Actually I don't need it, first I find the data and then comes the loop.

But I was wondering if the mobile devices are able to manage such kind of work, I'm doing some tests in a PocketPC and in a modern WM 6.5 phone, and I want good performance in both.

For example in the PocketPC it seems it refresh the info almost every second, although the interval of the timer is 100ms.
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Using a timer will not increase the performance of the system.
The Timer ticks are updated only every second, but the execution of code does't depend on that.
You can experience this when you have an operation the display is updated after completion of it. When you have a long operation then the system hangs up until completion of the operation, in this case if you want an update you must use the DoEvents statement.

Best regards.
 

Ariel_Z

Active Member
Licensed User
Diego, what do you need the timer for? Timers are used to carry out some operation in the background. For example: you have the table and the user refreshing it, and you can use a timer to check for database updates in the background. What is your need?
 

diego

Member
Licensed User
Longtime User
I need a timer because the program is a chronometer that looks for an "event" in the table every tick, for example,
I start the chrono and in my table I have "at 8:00 have breakfast,at 11:00 have lunch, etc." I need to seek every time in which position of the table am I. The event can happen at a part of a second, so I need the maximum accuracy.

So finally I have a Do-Loop in the timer_tick.

¿if I put the DoEvents statement in the Do..Loop I would "free" the timer until next tick?

thanks both
 

Ariel_Z

Active Member
Licensed User
No, this is not a very good idea.
Generally, you should try avoid using the DoEvents method. If you did you should have good reason, as it tends to cause performance penalty and there are usually ways to work around it. Using a Do-Loop in a timer is also not a very good idea due to the same reason.

A timer raises a certain sub every tick (x milliseconds). This sub can then do anything. I guess you've seen how it works. In your case, what you need is that the timer will seek the next time on a schedule and do something if it has arrived. I think it's best to look for the next thing to happen (in the table) when the previous ends and when the table updates. This way the timer only needs to compare the time now to a saved time and this is very quick.
 

agraham

Expert
Licensed User
Longtime User
The event can happen at a part of a second, so I need the maximum accuracy.
"Now" on a device only increments once per second so you cannot tell the time more accurately that that. A Timer however can tick more often than once per second.Why would you need more accuracy than a second? For the application you describe isn't it sufficient to test for "later than" to check an event time has arrived. I would have thought a check every few seconds was enough.
 

diego

Member
Licensed User
Longtime User
Ariel, I think you're right. I've removed the loop and added a variable as a pointer, If (Now) is greater than the time in the pointer, I move to the next row in the table. It seems it works.

Anyway in my old PocketPC 2002 (updated to 2003) with NetCF 2.0 I see a flicker that doesn't appear in the WM 6.5 phone.

The application is a kind of ability game (or will be,I hope)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…