Why won't my table add a row??

RandomCoder

Well-Known Member
Licensed User
Longtime User
I've been struggling with this for over half an hour now and I'm sure that it's somthing REALLY simple (which makes it even worse).
I've created a table and wish to add a new row each time a message is received. This is difficult to test and so for the time being I'm triggering the sub manually and just adding some values myself.
But this is where the problem starts.

Here's the snippet of code containing the problem...
B4X:
Sub Intercept_MessageReceived
[COLOR="Lime"]'Catch incoming messages
   'SMS.Value = Intercept.ReceivedMessage
   'TblSMSInbox.AddRow( SMS.DateReceived , SMS.From , SMS.Body )
   'Added just for test purposes[/COLOR]
   Received=Time(Now)
   From="Joe Blogs"
   Body="Hello"
   TblSMSInbox.Visible=True
   Msgbox(Received & " , " & From & " , " & Body )
   [COLOR="lime"]'TblSMSInbox.AddRow( Received , From , Body ) [/COLOR]         [COLOR="Red"]'THIS DOESNT WORK????????????[/COLOR]
   TblSMSInbox.AddRow( "" )                               [COLOR="red"]'THIS WILL WORK[/COLOR]
   ShowSMS
End Sub

As you can see, I've commented out sections that would normally grab the incoming SMS.Value and instead used some different variables.
Whenever I try to populate the table with any values other than null, the program errors.
WHY? What am I doing wrong?
I've even changed all the columns to cString which made no difference!

Attached is the full code which is most deffinately a work in progress.

Thanks,
RandomCoder
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
:sign0161: I should have realised that changing the column type to cString within my initialisation sub would do nothing as the file had already been created by then.
Why didn't I think of deleting the original SMSInbox.XML file??

Thanks for the help, told you it would be something really simple :sign0013:


You suggest that CSV might be better, why is that?
My intention is to replace my phones messaging program with one of my own.
I intend to filter messages as they arrive so that certain ones are automatically stored in a log file along with my replies so that I can compile a kind of diary record.

I had a brief look at SQL but where to start?
The SQL example uses an existing database and just shows how to run a query, I'd need to create it from scratch.

Also, (last question ;)), the inbox table will store all messages as they arrive, I then thought of using the node control to list the messages and select the desired one.
Is this the best approach? What events do nodes have? I've checked the help file and only properties are listed, the SQL example which uses nodes does not seem to have any events linked to the nodes but is there a better example for using nodes?

Your help is, as always, greatly appreciated.
Randomcoder
 

Cableguy

Expert
Licensed User
Longtime User
Hi! RandomCoder...
SQL was/is a free database so there are lots of free tools and tutorials on how to jump-start a database project...
I know this isn't very helpfull, but thought I'd say "Hi!"
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
I know this isn't very helpfull, but thought I'd say "Hi!"

Hi CableGuy :)

For a small-medium database you could just use the Table control.
Yes, the inbox could just be CSV as this isn't likely to grow very large and I could limit it's size just like most phones do.
But the log file could grow quite large, my Nokia 6600 has well in excess of 1500 messages stored on the external card.
So lets say for instance 2000 entries with around 7 fields for each, to allow search and filtering of the data.
Is that still within the small-medium database size for a device?
Thats why I was looking into SQL.

Regards,
RandomCoder
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
Thanks Erel.

But can I create a database directly from B4PPC using the table and SQL commands or do I need to use another third party software (as suggested by CableGuy) to initially create the database file? (I promise that this will be the last question from me on this subject ;))

Thanks,
RandomCoder
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
Feel free to ask any question! These are good question and will help others too.

You can create SQL tables without any third party software.
You should use CREATE TABLE: http://sqlite.org/lang_createtable.html

Thats fantastic, thanks for taking the time to reply.
I really don't know how you find the time to give such a high level of support :sign0188:

Thanks,
RandomCoder
 
Top