Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to create and set timer object in start.prg
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00943662
Message ID:
00943666
Views:
29
>Hi All,
>i'll develop a internal messaging system. And will be a msg.dbf and msgsend form on my project. But i want set a timer object in my start.prg from the start and timer object will detect new messages while user logging to the system and show it on a form ,if its not marked .t. (has been read) . How can i do this ? how would be the msd.dbf structure ? how would be the msgsend.scx structure ? and how can i set a timer in my start.prg will detect for a new messages for active user till user close the program ...
>
>all replies will be very appricated.. TIA

The simplest approach would be to have one form that is used for messages both sent and received. The top half could be a two page tabbed frame (1 page for Received and 1 page for Sent), the bottom half could be for viewing received messages or composing new messages.

A timer on the form checks for new messages at 1 minute intervals
timer.interval = 60 * 1000
The code in the timer event might look something like:
*- In the following assume the Direction field contains “R” for Received or “S” for Sent.
Select * ;
   From Messages ;
   Into Cursor curNewMessages ;
   Where UserID = SubStr( Sys(0), At( "#", Sys(0) ) + 2 ) ;
      And Direction = “R” ;
      And Not MessageRead
If  _Tally > 0 Then
   ThisForm.lblNewMessage.Visiible = .T.
   * Assume the following cursor was created using “Create Cursor” not an SQL Select.
   Select curReceived
   Append From Dbf(“curNewMessages”)
   Use In curNewMessages
Endif
Once all new messages have been viewed (MessageRead has been set to .T.) then
ThisForm.lblNewMessage.Visiible = .F.
In the Append above you will also need to add code to make sure that you do not keep on appending the same records every time the timer event fires.
censored.
Previous
Reply
Map
View

Click here to load this message in the networking platform