Author Topic: Best way to delete messages  (Read 2286 times)

jboavida

  • Newbie
  • *
  • Posts: 3
    • View Profile
Best way to delete messages
« on: January 19, 2009, 11:18:15 am »
Hi,
I'm evaluating this (so it seems) excellent VCL, and I have a question:

The system is going to detect a SMS, process it, store it in a database and delete it form the phone.
This is working fine.

But, in case that the PC is disconnected, the modem still gets is messages, so I need to check everytime that the appication is started if there are unread messages on the phone. I do that by using the SmsList that fires the SmsListItem event.
In this event I process the messages and delete them. My problem is here. I get timeouts. I think that the VCL uses the message index to control the loop or something.

Obviously I have to delete the messages out of the SmsListItem event. What and where is the best way to do it? Is there a way to delete all the messages at same time?

Thanks in advance

Joaquim
 

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Best way to delete messages
« Reply #1 on: January 19, 2009, 11:39:52 am »
Hello Joaquim

Thank you for your interest to our product.

About timeouts.
You can play with serial port settings for increase the stability of connection.

About mass deleting.
There is no such method.
We need think more before add so dangerous method into class :-)

You can call TnrGsm.SmsDelete(aIndex: integer) in loop and change Index from 1 up to maximum index of SMS for your phone.
This method can return False if SMS is not found but you can ignore this error.

Roman
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

jboavida

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Best way to delete messages
« Reply #2 on: January 19, 2009, 11:51:39 am »
Thanks Roman,

How about using a global variable that is incremented every time the SMSListItem is fired? In that way I will know the maximum number of SMS in the phone and use it the the delete loop. Is that Ok?

Tks

Joaquim

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Best way to delete messages
« Reply #3 on: January 19, 2009, 12:04:34 pm »
Joaquim

You can try to use code like following:

Code: [Select]
var MaxSmsIndex, i:integer;
begin
  nrGsm1.MemRead := 'ME';
  MaxSmsIndex := nrGsm1.MemReadTotal;
  for i := 1 to MaxSmsIndex do begin
     nrGsm1.SmsDelete(i);
     Application.ProcessMessages();
  end;
end;

Good luck!

Roman Novgorodov
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.