NetTalk Central

Author Topic: NetRefresh  (Read 11877 times)

Niels Larsen

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • Email
NetRefresh
« on: December 12, 2011, 04:10:10 AM »
Can someone show me how to implement NetRefresh manually on a window - if it can be done.

Regards Niels

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11197
    • View Profile
Re: NetRefresh
« Reply #1 on: December 12, 2011, 05:15:05 AM »
Can you be more specific on what you are trying to do Niels?

cheers
Bruce

Niels Larsen

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • Email
Re: NetRefresh
« Reply #2 on: December 12, 2011, 06:36:29 AM »
Hi Bruce.
Of course! I have a simple window with a lot of box controls. Each box changes color depending on the status of a fire engine.
Everything is controlled by a service on a server which should update my window.
/Niels

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11197
    • View Profile
Re: NetRefresh
« Reply #3 on: December 12, 2011, 07:24:57 AM »
ok - so is the server writing the info to a file? Or will it pipe the info directly to the client via TCP/IP?

cheers
Bruce

Niels Larsen

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • Email
Re: NetRefresh
« Reply #4 on: December 12, 2011, 09:47:49 AM »
For a file. And then the server sends a "refresh" to the client to reset the display.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11197
    • View Profile
Re: NetRefresh
« Reply #5 on: December 12, 2011, 10:55:48 PM »
ok, so clearly the problem is in 2 parts;

a) the server has to "send" a notification when the table updates _after_ the change is written to disk.

ThisNetRefresh.Send('|Contacts|')

Make sure there is a pipe char at the start and end of the string. You can add multiple tables to the list if you have updated multiple files.

ThisNetRefresh.Send('|Contacts|Invoices|')

b) The client window has to "respond" to the message. Obviously for a browse this is done by the template for you - the code looks like this;

variable declarations

NetLocalRefreshDate     Long   
NetLocalRefreshTime     Long
NetLocalDependancies    String('|Contacts|')

In the dependencies string you'll see again, the pipe separated list of table names, again with the pipe at the start and end of the string.

when you open the screen, or update it,

  NetLocalRefreshDate = today()       
  NetLocalRefreshTime = clock()

    If ThisNetRefresh.NeedReset(NetLocalRefreshDate,NetLocalRefreshTime,NetLocalDependancies)
      Self.Reset(1)                     
      BRW1.ResetFromBuffer()   
    End

You would obviously replace
      Self.Reset(1)                     
      BRW1.ResetFromBuffer()   

with whatever code you need to refresh your window.

Cheers
Bruce

Niels Larsen

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • Email
Re: NetRefresh
« Reply #6 on: December 14, 2011, 07:11:05 AM »
Hi Bruce

Thanks. But how do I trigger an event. Do I use a timer or ??
Ii works fine i the window gain focus.

/Niels

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11197
    • View Profile
Re: NetRefresh
« Reply #7 on: December 14, 2011, 08:04:14 AM »
yes, it works on "any event" - so if you want a consistent event (that does nothing) then I guess the timer event is a good idea.
Set it to say 500 (every 5 seconds) or something like that.

cheers
Bruce

Niels Larsen

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • Email
Re: NetRefresh
« Reply #8 on: December 20, 2011, 07:07:53 AM »
Hi Bruce

It should be easy. I have done exactly as you described, but I never get "NeedReset" to be TRUE. Have you got an idea to where I should look for the error?

/Niels

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11197
    • View Profile
Re: NetRefresh
« Reply #9 on: December 20, 2011, 10:04:36 PM »
Hi Niels,

does your application have a "frame" procedure, or is this window "on it's own" as an app?

cheers
Bruce


Niels Larsen

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • Email
Re: NetRefresh
« Reply #10 on: December 20, 2011, 10:49:13 PM »
Yes - I have a frame. I have a browse in the same app and NetRefresh works fine.
Strange....